List of usage examples for io.netty.buffer ByteBuf writeZero
public abstract ByteBuf writeZero(int length);
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPLspaObjectParser.java
License:Open Source License
@Override public void serializeObject(final Object object, final ByteBuf buffer) { Preconditions.checkArgument(object instanceof Lspa, "Wrong instance of PCEPObject. Passed %s. Needed LspaObject.", object.getClass()); final Lspa lspaObj = (Lspa) object; final ByteBuf body = Unpooled.buffer(); writeAttributeFilter(lspaObj.getExcludeAny(), body); writeAttributeFilter(lspaObj.getIncludeAny(), body); writeAttributeFilter(lspaObj.getIncludeAll(), body); writeUnsignedByte(lspaObj.getSetupPriority(), body); writeUnsignedByte(lspaObj.getHoldPriority(), body); final BitArray flags = new BitArray(FLAGS_SIZE); flags.set(L_FLAG_OFFSET, lspaObj.isLocalProtectionDesired()); flags.toByteBuf(body);//from w w w. j a v a 2 s .c o m body.writeZero(RESERVED); serializeTlvs(lspaObj.getTlvs(), body); ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPMetricObjectParser.java
License:Open Source License
@Override public void serializeObject(final Object object, final ByteBuf buffer) { Preconditions.checkArgument(object instanceof Metric, "Wrong instance of PCEPObject. Passed %s. Needed MetricObject.", object.getClass()); final Metric mObj = (Metric) object; final ByteBuf body = Unpooled.buffer(SIZE); body.writeZero(RESERVED); final BitArray flags = new BitArray(FLAGS_SIZE); flags.set(C_FLAG_OFFSET, mObj.isComputed()); flags.set(B_FLAG_OFFSET, mObj.isBound()); flags.toByteBuf(body);//from w w w . jav a2s . co m Preconditions.checkArgument(mObj.getMetricType() != null, "MetricType is mandatory."); writeUnsignedByte(mObj.getMetricType(), body); writeFloat32(mObj.getValue(), body); ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPMonitoringObjectParser.java
License:Open Source License
@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);//w ww . j a v a 2 s . c o m ByteBufWriteUtil.writeUnsignedInt(monitoring.getMonitoringId(), body); serializeTlvs(monitoring.getTlvs(), body); ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPNoPathObjectParser.java
License:Open Source License
@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);/* w ww .j a v a 2 s. c o m*/ body.writeZero(RESERVED_F_LENGTH); serializeTlvs(nPObj.getTlvs(), body); ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPNotificationObjectParser.java
License:Open Source License
@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); }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPObjectiveFunctionObjectParser.java
License:Open Source License
@Override public void serializeObject(final Object object, final ByteBuf buffer) { Preconditions.checkArgument(object instanceof Of, "Wrong instance of PCEPObject. Passed %s. Needed OfObject.", object.getClass()); final Of specObj = (Of) object; final ByteBuf body = Unpooled.buffer(); Preconditions.checkArgument(specObj.getCode() != null, "Code is mandatory"); writeUnsignedShort(specObj.getCode().getValue(), body); body.writeZero(RESERVED); serializeTlvs(specObj.getTlvs(), body); ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPOverloadObjectParser.java
License:Open Source License
@Override public void serializeObject(final Object object, final ByteBuf buffer) { Preconditions.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); ByteBufWriteUtil.writeUnsignedShort(overload.getDuration(), body); ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPProcTimeObjectParser.java
License:Open Source License
@Override public void serializeObject(final Object object, final ByteBuf buffer) { Preconditions.checkArgument(object instanceof ProcTime, "Wrong instance of PCEPObject. Passed %s. Needed ProcTimeObject.", object.getClass()); final ProcTime procTime = (ProcTime) object; final ByteBuf body = Unpooled.buffer(BODY_SIZE); body.writeZero(RESERVED); final BitArray flagBits = new BitArray(FLAGS); flagBits.set(E_FLAG_POSITION, procTime.isEstimated()); flagBits.toByteBuf(body);//from w w w .j a v a2 s. c o m ByteBufWriteUtil.writeUnsignedInt(procTime.getCurrentProcTime(), body); ByteBufWriteUtil.writeUnsignedInt(procTime.getMinProcTime(), body); ByteBufWriteUtil.writeUnsignedInt(procTime.getMaxProcTime(), body); ByteBufWriteUtil.writeUnsignedInt(procTime.getAverageProcTime(), body); ByteBufWriteUtil.writeUnsignedInt(procTime.getVarianceProcTime(), body); ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPSvecObjectParser.java
License:Open Source License
@Override public void serializeObject(final Object object, final ByteBuf buffer) { Preconditions.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.isLinkDiverse()); flags.set(N_FLAG_OFFSET, svecObj.isNodeDiverse()); flags.set(S_FLAG_OFFSET, svecObj.isSrlgDiverse()); flags.toByteBuf(body);/*from w ww . j ava 2 s .c om*/ final List<RequestId> requestIDs = svecObj.getRequestsIds(); assert !(requestIDs.isEmpty()) : "Empty Svec Object - no request ids."; for (final RequestId requestId : requestIDs) { writeUnsignedInt(requestId.getValue(), body); } ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); }
From source file:org.opendaylight.protocol.pcep.impl.subobject.EROIpv4PrefixSubobjectParser.java
License:Open Source License
@Override public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) { Preconditions.checkArgument(subobject.getSubobjectType() instanceof IpPrefixCase, "Unknown subobject instance. Passed %s. Needed IpPrefixCase.", subobject.getSubobjectType().getClass()); final IpPrefixSubobject specObj = ((IpPrefixCase) subobject.getSubobjectType()).getIpPrefix(); final IpPrefix prefix = specObj.getIpPrefix(); Preconditions.checkArgument(prefix.getIpv4Prefix() != null || prefix.getIpv6Prefix() != null, "Unknown AbstractPrefix instance. Passed %s.", prefix.getClass()); if (prefix.getIpv6Prefix() != null) { new EROIpv6PrefixSubobjectParser().serializeSubobject(subobject, buffer); } else {// w w w .java 2 s . c o m final ByteBuf body = Unpooled.buffer(CONTENT4_LENGTH); Preconditions.checkArgument(prefix.getIpv4Prefix() != null, "Ipv4Prefix is mandatory."); writeIpv4Prefix(prefix.getIpv4Prefix(), body); body.writeZero(RESERVED); EROSubobjectUtil.formatSubobject(TYPE, subobject.isLoose(), body, buffer); } }