use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.attributes.object.lsp.attributes.object.SubobjectContainer in project bgpcep by opendaylight.
the class XROPathKey32SubobjectParser method serializeSubobject.
@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
Preconditions.checkArgument(subobject.getSubobjectType() instanceof PathKeyCase, "Unknown subobject instance.Passed %s. Needed PathKey.", subobject.getSubobjectType().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) subobject.getSubobjectType()).getPathKey();
final ByteBuf body = serializePathKey(pk);
if (pk.getPceId().getBinary().length == PCE_ID_F_LENGTH) {
XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
} else if (pk.getPceId().getBinary().length == XROPathKey128SubobjectParser.PCE128_ID_F_LENGTH) {
XROSubobjectUtil.formatSubobject(XROPathKey128SubobjectParser.TYPE, subobject.isMandatory(), body, buffer);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.attributes.object.lsp.attributes.object.SubobjectContainer in project bgpcep by opendaylight.
the class XROSrlgSubobjectParser method serializeSubobject.
@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
Preconditions.checkArgument(subobject.getSubobjectType() instanceof SrlgCase, "Unknown subobject instance. Passed %s. Needed SrlgCase.", subobject.getSubobjectType().getClass());
final SrlgSubobject specObj = ((SrlgCase) subobject.getSubobjectType()).getSrlg();
final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
Preconditions.checkArgument(specObj.getSrlgId() != null, "SrlgId is mandatory.");
writeUnsignedInt(specObj.getSrlgId().getValue(), body);
Preconditions.checkArgument(subobject.getAttribute() != null, "Attribute is mandatory.");
writeUnsignedByte(null, body);
writeUnsignedByte((short) subobject.getAttribute().getIntValue(), body);
XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.attributes.object.lsp.attributes.object.SubobjectContainer in project bgpcep by opendaylight.
the class XROUnnumberedInterfaceSubobjectParser 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);
writeUnsignedByte(subobject.getAttribute() != null ? (short) subobject.getAttribute().getIntValue() : null, body);
serializeUnnumeredInterface(((UnnumberedCase) subobject.getSubobjectType()).getUnnumbered(), body);
XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.attributes.object.lsp.attributes.object.SubobjectContainer in project bgpcep by opendaylight.
the class AttributesObjectParser method localParseObject.
@Override
protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
final LspAttributesObjectBuilder builder = new LspAttributesObjectBuilder();
final List<SubobjectContainer> subObjectList = new ArrayList<>();
while (byteBuf.isReadable()) {
final int type = byteBuf.readUnsignedShort();
final int length = byteBuf.readUnsignedShort();
final ByteBuf value = byteBuf.readSlice(length);
final SubobjectContainerBuilder subObj = new SubobjectContainerBuilder();
if (type == FLAG_TLV_TYPE) {
subObj.setLspSubobject(new FlagsTlvBuilder().setFlagContainer(parseFlag(value)).build());
} else {
LOG.warn("Lsp Attributes Subobject type {} not supported", type);
}
subObjectList.add(subObj.build());
}
return builder.setSubobjectContainer(subObjectList).build();
}
Aggregations