use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId in project bgpcep by opendaylight.
the class PCEPRequestParameterObjectParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
Preconditions.checkArgument(object instanceof Rp, "Wrong instance of PCEPObject. Passed %s. Needed RPObject.", object.getClass());
final ByteBuf body = Unpooled.buffer();
final Rp rpObj = (Rp) object;
final BitArray flags = new BitArray(FLAGS_SIZE);
flags.set(R_FLAG_OFFSET, rpObj.isReoptimization());
flags.set(B_FLAG_OFFSET, rpObj.isBiDirectional());
flags.set(O_FLAG_OFFSET, rpObj.isLoose());
flags.set(M_FLAG_OFFSET, rpObj.isMakeBeforeBreak());
flags.set(D_FLAG_OFFSET, rpObj.isOrder());
flags.set(P_FLAG_OFFSET, rpObj.isPathKey());
flags.set(S_FLAG_OFFSET, rpObj.isSupplyOf());
flags.set(F_FLAG_OFFSET, rpObj.isFragmentation());
flags.set(N_FLAG_OFFSET, rpObj.isP2mp());
flags.set(E_FLAG_OFFSET, rpObj.isEroCompression());
final byte[] res = flags.array();
if (rpObj.getPriority() != null) {
final byte p = UnsignedBytes.checkedCast(rpObj.getPriority());
res[res.length - 1] = (byte) (res[res.length - 1] | p);
}
body.writeBytes(res);
Preconditions.checkArgument(rpObj.getRequestId() != null, "RequestId is mandatory");
writeUnsignedInt(rpObj.getRequestId().getValue(), body);
serializeTlvs(rpObj.getTlvs(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId in project bgpcep by opendaylight.
the class PCEPSvecObjectParser method parseObject.
@Override
public Svec parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
if (bytes.readableBytes() < MIN_SIZE) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.readableBytes() + "; Expected: >=" + MIN_SIZE + ".");
}
bytes.skipBytes(FLAGS_F_OFFSET);
final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE);
final List<RequestId> requestIDs = Lists.newArrayList();
while (bytes.isReadable()) {
requestIDs.add(new RequestId(bytes.readUnsignedInt()));
}
if (requestIDs.isEmpty()) {
throw new PCEPDeserializerException("Empty Svec Object - no request ids.");
}
final SvecBuilder builder = new SvecBuilder();
builder.setIgnore(header.isIgnore());
builder.setProcessingRule(header.isProcessingRule());
builder.setLinkDiverse(flags.get(L_FLAG_OFFSET));
builder.setNodeDiverse(flags.get(N_FLAG_OFFSET));
builder.setSrlgDiverse(flags.get(S_FLAG_OFFSET));
builder.setRequestsIds(requestIDs);
return builder.build();
}
Aggregations