use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.NoPathVectorTlv.Flags in project bgpcep by opendaylight.
the class PCEPNoPathObjectParser method parseObject.
@Override
public NoPath parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
final Uint8 issue = ByteBufUtils.readUint8(bytes);
final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE);
bytes.skipBytes(RESERVED_F_LENGTH);
final TlvsBuilder tlvsBuilder = new TlvsBuilder();
parseTlvs(tlvsBuilder, bytes.slice());
return new NoPathBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setNatureOfIssue(issue).setUnsatisfiedConstraints(flags.get(C_FLAG_OFFSET)).setTlvs(tlvsBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.NoPathVectorTlv.Flags in project bgpcep by opendaylight.
the class PCEPNoPathObjectParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
checkArgument(object instanceof NoPath, "Wrong instance of PCEPObject. Passed %s. Needed NoPathObject.", object.getClass());
final NoPath nPObj = (NoPath) object;
final ByteBuf body = Unpooled.buffer();
ByteBufUtils.writeMandatory(body, nPObj.getNatureOfIssue(), "NatureOfIssue");
final BitArray flags = new BitArray(FLAGS_SIZE);
flags.set(C_FLAG_OFFSET, nPObj.getUnsatisfiedConstraints());
flags.toByteBuf(body);
body.writeZero(RESERVED_F_LENGTH);
serializeTlvs(nPObj.getTlvs(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.getProcessingRule(), object.getIgnore(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.NoPathVectorTlv.Flags in project bgpcep by opendaylight.
the class PCEPOverloadObjectParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
checkArgument(object instanceof Overload, "Wrong instance of PCEPObject. Passed %s. Needed OverloadObject.", object.getClass());
final Overload overload = (Overload) object;
final ByteBuf body = Unpooled.buffer(BODY_SIZE);
body.writeZero(RESERVED + FLAGS);
ByteBufUtils.writeOrZero(body, overload.getDuration());
ObjectUtil.formatSubobject(TYPE, CLASS, object.getProcessingRule(), object.getIgnore(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.NoPathVectorTlv.Flags in project bgpcep by opendaylight.
the class RROUnnumberedInterfaceSubobjectParser method parseSubobject.
@Override
public Subobject parseSubobject(final ByteBuf buffer) throws PCEPDeserializerException {
checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
if (buffer.readableBytes() != CONTENT_LENGTH) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: " + CONTENT_LENGTH + ".");
}
final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
buffer.skipBytes(RESERVED);
return new SubobjectBuilder().setProtectionAvailable(flags.get(LPA_F_OFFSET)).setProtectionInUse(flags.get(LPIU_F_OFFSET)).setSubobjectType(new UnnumberedCaseBuilder().setUnnumbered(new UnnumberedBuilder().setRouterId(ByteBufUtils.readUint32(buffer)).setInterfaceId(ByteBufUtils.readUint32(buffer)).build()).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.NoPathVectorTlv.Flags in project bgpcep by opendaylight.
the class PCEPSvecObjectParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
checkArgument(object instanceof Svec, "Wrong instance of PCEPObject. Passed %s. Needed SvecObject.", object.getClass());
final Svec svecObj = (Svec) object;
final ByteBuf body = Unpooled.buffer();
body.writeZero(FLAGS_F_OFFSET);
final BitArray flags = new BitArray(FLAGS_SIZE);
flags.set(L_FLAG_OFFSET, svecObj.getLinkDiverse());
flags.set(N_FLAG_OFFSET, svecObj.getNodeDiverse());
flags.set(S_FLAG_OFFSET, svecObj.getSrlgDiverse());
flags.set(D_FLAG_OFFSET, svecObj.getLinkDirectionDiverse());
flags.set(P_FLAG_OFFSET, svecObj.getPartialPathDiverse());
flags.toByteBuf(body);
final List<RequestId> requestIDs = svecObj.getRequestsIds();
// FIXME: remove this assert
assert !requestIDs.isEmpty() : "Empty Svec Object - no request ids.";
for (final RequestId requestId : requestIDs) {
ByteBufUtils.write(body, requestId.getValue());
}
ObjectUtil.formatSubobject(TYPE, CLASS, object.getProcessingRule(), object.getIgnore(), body, buffer);
}
Aggregations