use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.SvecBuilder in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method getValidSvec.
// Note: objects is expected to be non-empty
private static Svec getValidSvec(final SvecBuilder builder, final Queue<Object> objects) {
final Object svec = objects.element();
if (svec instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.Svec) {
builder.setSvec((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.Svec) svec);
objects.remove();
} else {
return null;
}
// FIXME: this list is not retained anywhere
final List<Metrics> metrics = new ArrayList<>();
final List<VendorInformationObject> viObjects = new ArrayList<>();
SvecState state = SvecState.INIT;
for (Object obj = objects.peek(); obj != null; obj = objects.peek()) {
state = insertP2PObject(state, obj, builder, metrics, viObjects);
if (state == SvecState.END) {
break;
}
objects.remove();
}
if (!viObjects.isEmpty()) {
builder.setVendorInformationObject(viObjects);
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.SvecBuilder in project bgpcep by opendaylight.
the class PCEPSvecObjectParser method parseObject.
@Override
public Svec 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.");
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 = new ArrayList<>();
while (bytes.isReadable()) {
requestIDs.add(new RequestId(ByteBufUtils.readUint32(bytes)));
}
if (requestIDs.isEmpty()) {
throw new PCEPDeserializerException("Empty Svec Object - no request ids.");
}
return new SvecBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setLinkDiverse(flags.get(L_FLAG_OFFSET)).setNodeDiverse(flags.get(N_FLAG_OFFSET)).setSrlgDiverse(flags.get(S_FLAG_OFFSET)).setLinkDirectionDiverse(flags.get(D_FLAG_OFFSET)).setPartialPathDiverse(flags.get(P_FLAG_OFFSET)).setRequestsIds(requestIDs).build();
}
Aggregations