use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.SubobjectType in project bgpcep by opendaylight.
the class XROUnnumberedInterfaceSubobjectParser 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 ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
body.writeZero(RESERVED);
final Attribute attribute = subobject.getAttribute();
body.writeByte(attribute != null ? attribute.getIntValue() : 0);
serializeUnnumeredInterface(((UnnumberedCase) type).getUnnumbered(), body);
XROSubobjectUtil.formatSubobject(TYPE, subobject.getMandatory(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.SubobjectType in project bgpcep by opendaylight.
the class AbstractEROPathKeySubobjectParser method serializeSubobject.
@Override
public final void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
final SubobjectType type = subobject.getSubobjectType();
checkArgument(type instanceof PathKeyCase, "Unknown subobject instance. Passed %s. Needed PathKey.", type.getClass());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKey pk = ((PathKeyCase) type).getPathKey();
final PathKey pathKey = pk.getPathKey();
checkArgument(pathKey != null, "PathKey is mandatory.");
final byte[] pceID = pk.getPceId().getValue();
checkArgument(pceID.length == PCE_ID_F_LENGTH || pceID.length == PCE128_ID_F_LENGTH, "PceId 32/128 Bit required.");
final ByteBuf body = Unpooled.buffer();
ByteBufUtils.write(body, pathKey.getValue());
body.writeBytes(pceID);
EROSubobjectUtil.formatSubobject(pceID.length == PCE_ID_F_LENGTH ? TYPE_32 : TYPE_128, subobject.getLoose(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.SubobjectType in project bgpcep by opendaylight.
the class XROPathKey128SubobjectParser method serializeSubobject.
public static void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
final SubobjectType type = subobject.getSubobjectType();
checkArgument(type instanceof PathKeyCase, "Unknown subobject instance. Passed %s. Needed PathKey.", type.getClass());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKey pk = ((PathKeyCase) type).getPathKey();
final ByteBuf body = Unpooled.buffer();
final PathKey pathKey = pk.getPathKey();
checkArgument(pathKey != null, "PathKey is mandatory.");
ByteBufUtils.write(body, pathKey.getValue());
final PceId pceId = pk.getPceId();
checkArgument(pceId != null, "PceId is mandatory.");
body.writeBytes(pceId.getValue());
XROSubobjectUtil.formatSubobject(TYPE, subobject.getMandatory(), body, buffer);
}
Aggregations