use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project bgpcep by opendaylight.
the class PCEPMonitoringObjectParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
Preconditions.checkArgument(object instanceof Monitoring, "Wrong instance of PCEPObject. Passed %s. Needed MonitoringObject.", object.getClass());
final Monitoring monitoring = (Monitoring) object;
final ByteBuf body = Unpooled.buffer();
body.writeZero(RESERVED);
final Flags flags = monitoring.getFlags();
final BitArray flagBits = new BitArray(FLAGS_SIZE);
flagBits.set(I_FLAG_POS, flags.isIncomplete());
flagBits.set(C_FLAG_POS, flags.isOverload());
flagBits.set(P_FLAG_POS, flags.isProcessingTime());
flagBits.set(G_FLAG_POS, flags.isGeneral());
flagBits.set(L_FLAG_POS, flags.isLiveness());
flagBits.toByteBuf(body);
ByteBufWriteUtil.writeUnsignedInt(monitoring.getMonitoringId(), body);
serializeTlvs(monitoring.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.Object in project bgpcep by opendaylight.
the class PCEPMonitoringObjectParser method parseObject.
@Override
public Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final MonitoringBuilder builder = new MonitoringBuilder();
buffer.readBytes(RESERVED);
final BitArray flagBits = BitArray.valueOf(buffer, FLAGS_SIZE);
final Flags flags = new Flags(flagBits.get(G_FLAG_POS), flagBits.get(I_FLAG_POS), flagBits.get(L_FLAG_POS), flagBits.get(C_FLAG_POS), flagBits.get(P_FLAG_POS));
builder.setFlags(flags);
builder.setMonitoringId(buffer.readUnsignedInt());
final TlvsBuilder tbuilder = new TlvsBuilder();
parseTlvs(tbuilder, buffer.slice());
builder.setTlvs(tbuilder.build());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project bgpcep by opendaylight.
the class PCEPNoPathObjectParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
Preconditions.checkArgument(object instanceof NoPath, "Wrong instance of PCEPObject. Passed %s. Needed NoPathObject.", object.getClass());
final NoPath nPObj = (NoPath) object;
final ByteBuf body = Unpooled.buffer();
Preconditions.checkArgument(nPObj.getNatureOfIssue() != null, "NatureOfIssue is mandatory.");
writeUnsignedByte(nPObj.getNatureOfIssue(), body);
final BitArray flags = new BitArray(FLAGS_SIZE);
flags.set(C_FLAG_OFFSET, nPObj.isUnsatisfiedConstraints());
flags.toByteBuf(body);
body.writeZero(RESERVED_F_LENGTH);
serializeTlvs(nPObj.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.Object in project bgpcep by opendaylight.
the class PCEPNotificationObjectParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
Preconditions.checkArgument(object instanceof CNotification, "Wrong instance of PCEPObject. Passed %s. Needed CNotificationObject.", object.getClass());
final CNotification notObj = (CNotification) object;
final ByteBuf body = Unpooled.buffer();
body.writeZero(NT_F_OFFSET);
Preconditions.checkArgument(notObj.getType() != null, "Type is mandatory.");
writeUnsignedByte(notObj.getType(), body);
Preconditions.checkArgument(notObj.getValue() != null, "Value is mandatory.");
writeUnsignedByte(notObj.getValue(), body);
serializeTlvs(notObj.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.Object in project bgpcep by opendaylight.
the class PCEPOpenObjectParser method parseObject.
@Override
public Object 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.");
final int versionValue = ByteArray.copyBitsRange(bytes.readByte(), VERSION_SF_OFFSET, VERSION_SF_LENGTH);
final OpenBuilder builder = new OpenBuilder();
builder.setVersion(new ProtocolVersion((short) versionValue));
builder.setProcessingRule(header.isProcessingRule());
builder.setIgnore(header.isIgnore());
final short keepalive = bytes.readUnsignedByte();
builder.setKeepalive(keepalive);
final short deadTimer = bytes.readUnsignedByte();
if (keepalive == 0) {
builder.setDeadTimer((short) 0);
} else {
builder.setDeadTimer(deadTimer);
}
builder.setSessionId(bytes.readUnsignedByte());
final TlvsBuilder tbuilder = new TlvsBuilder();
parseTlvs(tbuilder, bytes.slice());
builder.setTlvs(tbuilder.build());
final Open obj = builder.build();
if (versionValue != PCEP_VERSION) {
// TODO: Should we move this check into the negotiator
LOG.debug("Unsupported PCEP version {}", versionValue);
return new UnknownObject(PCEPErrors.PCEP_VERSION_NOT_SUPPORTED, obj);
}
return obj;
}
Aggregations