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 Subobject subobject, final ByteBuf buffer) {
checkArgument(subobject.getSubobjectType() instanceof UnnumberedCase, "Unknown subobject instance. Passed %s. Needed UnnumberedCase.", subobject.getSubobjectType().getClass());
final UnnumberedSubobject specObj = ((UnnumberedCase) subobject.getSubobjectType()).getUnnumbered();
final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
body.writeZero(RESERVED);
ByteBufUtils.writeMandatory(body, specObj.getRouterId(), "RouterId");
ByteBufUtils.writeMandatory(body, specObj.getInterfaceId(), "InterfaceId");
EROSubobjectUtil.formatSubobject(TYPE, subobject.getLoose(), body, buffer);
}
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 XROUnnumberedInterfaceSubobjectParser method serializeSubobject.
@Override
public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
checkArgument(subobject.getSubobjectType() instanceof UnnumberedCase, "Unknown subobject instance. Passed %s. Needed UnnumberedCase.", subobject.getSubobjectType().getClass());
final UnnumberedSubobject specObj = ((UnnumberedCase) subobject.getSubobjectType()).getUnnumbered();
final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
body.writeZero(RESERVED);
final Attribute attribute = subobject.getAttribute();
body.writeByte(attribute != null ? attribute.getIntValue() : 0);
ByteBufUtils.writeMandatory(body, specObj.getRouterId(), "RouterId");
ByteBufUtils.writeMandatory(body, specObj.getInterfaceId(), "InterfaceId");
XROSubobjectUtil.formatSubobject(TYPE, subobject.getMandatory(), body, buffer);
}
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 UnnumberedInterfaceSubobjectUtilsTest 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 = UnnumberedInterfaceSubobjectUtils.parseUnnumeredInterface(input);
assertEquals(this.routerId, output.getUnnumbered().getRouterId());
assertEquals(this.interfaceId, output.getUnnumbered().getInterfaceId());
final ByteBuf bytebuf = Unpooled.buffer(8);
UnnumberedInterfaceSubobjectUtils.serializeUnnumeredInterface(output.getUnnumbered(), bytebuf);
assertArrayEquals(input.array(), bytebuf.array());
}
Aggregations