Search in sources :

Example 1 with UnnumberedCase

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

the class RROUnnumberedInterfaceSubobjectParser method serializeSubobject.

@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
    final SubobjectType type = subobject.getSubobjectType();
    checkArgument(type instanceof UnnumberedCase, "Unknown subobject instance. Passed %s. Needed UnnumberedCase.", type.getClass());
    final BitArray flags = new BitArray(FLAGS_SIZE);
    flags.set(LPA_F_OFFSET, subobject.getProtectionAvailable());
    flags.set(LPIU_F_OFFSET, subobject.getProtectionInUse());
    final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
    flags.toByteBuf(body);
    body.writeZero(RESERVED);
    final UnnumberedSubobject specObj = ((UnnumberedCase) type).getUnnumbered();
    ByteBufUtils.writeMandatory(body, specObj.getRouterId(), "RouterId");
    ByteBufUtils.writeMandatory(body, specObj.getInterfaceId(), "InterfaceId");
    RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
}
Also used : SubobjectType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.SubobjectType) UnnumberedCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.subobject.type.UnnumberedCase) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf) UnnumberedSubobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.UnnumberedSubobject)

Example 2 with UnnumberedCase

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

the class SEROBasicProtectionSubobjectParser method serializeSubobject.

@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
    Preconditions.checkArgument(subobject.getSubobjectType() instanceof BasicProtectionCase, "Unknown subobject instance. Passed %s. Needed UnnumberedCase.", subobject.getSubobjectType());
    final ProtectionSubobject protObj = ((BasicProtectionCase) subobject.getSubobjectType()).getBasicProtection().getProtectionSubobject();
    final ByteBuf body = Unpooled.buffer();
    serializeBody(CTYPE, protObj, body);
    EROSubobjectUtil.formatSubobject(TYPE, subobject.getLoose(), body, buffer);
}
Also used : BasicProtectionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.explicit.route.subobjects.subobject.type.BasicProtectionCase) ByteBuf(io.netty.buffer.ByteBuf) ProtectionSubobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.subobject.ProtectionSubobject)

Example 3 with UnnumberedCase

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

the class CommonUnnumberedInterfaceSubobjectParser method parseUnnumeredInterface.

protected static UnnumberedCase parseUnnumeredInterface(final ByteBuf buffer) {
    final UnnumberedBuilder ubuilder = new UnnumberedBuilder();
    ubuilder.setRouterId(buffer.readUnsignedInt());
    ubuilder.setInterfaceId(buffer.readUnsignedInt());
    return new UnnumberedCaseBuilder().setUnnumbered(ubuilder.build()).build();
}
Also used : UnnumberedCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.UnnumberedCaseBuilder) UnnumberedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.unnumbered._case.UnnumberedBuilder)

Example 4 with UnnumberedCase

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

the class CUISubobjectParserTest method testProcessing.

@Test
public void testProcessing() {
    final ByteBuf input = Unpooled.buffer(8);
    input.writeInt(this.routerId.intValue());
    input.writeInt(this.interfaceId.intValue());
    final UnnumberedCase output = CommonUnnumberedInterfaceSubobjectParser.parseUnnumeredInterface(input);
    assertEquals(this.routerId, output.getUnnumbered().getRouterId());
    assertEquals(this.interfaceId, output.getUnnumbered().getInterfaceId());
    final ByteBuf bytebuf = Unpooled.buffer(8);
    CommonUnnumberedInterfaceSubobjectParser.serializeUnnumeredInterface(output.getUnnumbered(), bytebuf);
    assertArrayEquals(input.array(), bytebuf.array());
}
Also used : UnnumberedCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.UnnumberedCase) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 5 with UnnumberedCase

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

the class EROUnnumberedInterfaceSubobjectParser method serializeSubobject.

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

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)12 UnnumberedCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.UnnumberedCase)6 UnnumberedSubobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.UnnumberedSubobject)4 ProtectionSubobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.subobject.ProtectionSubobject)4 Test (org.junit.Test)2 BitArray (org.opendaylight.protocol.util.BitArray)2 Attribute (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ExcludeRouteSubobjects.Attribute)2 UnnumberedCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.subobject.type.UnnumberedCase)2 SubobjectType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.SubobjectType)1 SubobjectType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.SubobjectType)1 UnnumberedCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.UnnumberedCaseBuilder)1 UnnumberedBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.unnumbered._case.UnnumberedBuilder)1 BasicProtectionCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary._record.route.subobjects.subobject.type.BasicProtectionCase)1 DynamicControlProtectionCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary._record.route.subobjects.subobject.type.DynamicControlProtectionCase)1 BasicProtectionCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.explicit.route.subobjects.subobject.type.BasicProtectionCase)1 DynamicControlProtectionCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.explicit.route.subobjects.subobject.type.DynamicControlProtectionCase)1