use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PlspId in project bgpcep by opendaylight.
the class StatefulLspObjectParser method parseObject.
@Override
public Lsp parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final LspBuilder builder = new LspBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule());
final int[] plspIdRaw = new int[] { bytes.readUnsignedByte(), bytes.readUnsignedByte(), bytes.getUnsignedByte(2) };
builder.setPlspId(new PlspId(Uint32.valueOf(plspIdRaw[0] << FLAGS_SIZE | plspIdRaw[1] << FOUR_BITS_SHIFT | plspIdRaw[2] >> FOUR_BITS_SHIFT)));
parseFlags(builder, bytes);
final TlvsBuilder b = new TlvsBuilder();
parseTlvs(b, bytes.slice());
builder.setTlvs(b.build());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PlspId in project bgpcep by opendaylight.
the class StatefulLspObjectParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
checkArgument(object instanceof Lsp, "Wrong instance of PCEPObject. Passed %s . Needed LspObject.", object.getClass());
final Lsp specObj = (Lsp) object;
final ByteBuf body = Unpooled.buffer();
final PlspId plspId = specObj.getPlspId();
checkArgument(plspId != null, "PLSP-ID not present");
body.writeMedium(plspId.getValue().intValue() << FOUR_BITS_SHIFT);
final BitArray flags = serializeFlags(specObj);
byte op = 0;
if (specObj.getOperational() != null) {
op = UnsignedBytes.checkedCast(specObj.getOperational().getIntValue());
op = (byte) (op << FOUR_BITS_SHIFT);
}
final byte[] res = flags.array();
res[res.length - 1] = (byte) (res[res.length - 1] | op);
body.writeByte(res[res.length - 1]);
serializeTlvs(specObj.getTlvs(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.getProcessingRule(), object.getIgnore(), body, buffer);
}
Aggregations