List of usage examples for io.netty.buffer ByteBuf writeZero
public abstract ByteBuf writeZero(int length);
From source file:org.opendaylight.protocol.pcep.impl.subobject.EROIpv6PrefixSubobjectParser.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(); final ByteBuf body = Unpooled.buffer(); Preconditions.checkArgument(prefix.getIpv6Prefix() != null, "Ipv6Prefix is mandatory."); writeIpv6Prefix(prefix.getIpv6Prefix(), body); body.writeZero(RESERVED); EROSubobjectUtil.formatSubobject(TYPE, subobject.isLoose(), body, buffer); }
From source file:org.opendaylight.protocol.pcep.impl.subobject.EROUnnumberedInterfaceSubobjectParser.java
License:Open Source License
@Override public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) { Preconditions.checkArgument(subobject.getSubobjectType() instanceof UnnumberedCase, "Unknown subobject instance. Passed %s. Needed UnnumberedCase.", subobject.getSubobjectType().getClass()); final UnnumberedSubobject specObj = ((UnnumberedCase) subobject.getSubobjectType()).getUnnumbered(); final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH); body.writeZero(RESERVED); Preconditions.checkArgument(specObj.getRouterId() != null, "RouterId is mandatory."); writeUnsignedInt(specObj.getRouterId(), body); Preconditions.checkArgument(specObj.getInterfaceId() != null, "InterfaceId is mandatory"); writeUnsignedInt(specObj.getInterfaceId(), body); EROSubobjectUtil.formatSubobject(TYPE, subobject.isLoose(), body, buffer); }
From source file:org.opendaylight.protocol.pcep.impl.subobject.RROUnnumberedInterfaceSubobjectParser.java
License:Open Source License
@Override public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) { Preconditions.checkArgument(subobject.getSubobjectType() instanceof UnnumberedCase, "Unknown subobject instance. Passed %s. Needed UnnumberedCase.", subobject.getSubobjectType().getClass()); final UnnumberedSubobject specObj = ((UnnumberedCase) subobject.getSubobjectType()).getUnnumbered(); final BitArray flags = new BitArray(FLAGS_SIZE); flags.set(LPA_F_OFFSET, subobject.isProtectionAvailable()); flags.set(LPIU_F_OFFSET, subobject.isProtectionInUse()); final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH); flags.toByteBuf(body);// ww w. ja va2 s . c o m body.writeZero(RESERVED); Preconditions.checkArgument(specObj.getRouterId() != null, "RouterId is mandatory."); writeUnsignedInt(specObj.getRouterId(), body); Preconditions.checkArgument(specObj.getInterfaceId() != null, "InterfaceId is mandatory."); writeUnsignedInt(specObj.getInterfaceId(), body); RROSubobjectUtil.formatSubobject(TYPE, body, buffer); }
From source file:org.opendaylight.protocol.pcep.impl.subobject.XROUnnumberedInterfaceSubobjectParser.java
License:Open Source License
@Override public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) { Preconditions.checkArgument(subobject.getSubobjectType() instanceof UnnumberedCase, "Unknown subobject instance. Passed %s. Needed UnnumberedCase.", subobject.getSubobjectType().getClass()); final UnnumberedSubobject specObj = ((UnnumberedCase) subobject.getSubobjectType()).getUnnumbered(); final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH); body.writeZero(RESERVED); writeUnsignedByte(subobject.getAttribute() != null ? (short) subobject.getAttribute().getIntValue() : null, body);/* w w w. j ava2 s . com*/ Preconditions.checkArgument(specObj.getRouterId() != null, "RouterId is mandatory."); writeUnsignedInt(specObj.getRouterId(), body); Preconditions.checkArgument(specObj.getInterfaceId() != null, "InterfaceId is mandatory."); writeUnsignedInt(specObj.getInterfaceId(), body); XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer); }
From source file:org.opendaylight.protocol.pcep.impl.tlv.PathSetupTypeTlvParser.java
License:Open Source License
@Override public void serializeTlv(final Tlv tlv, final ByteBuf buffer) { Preconditions.checkArgument(tlv instanceof PathSetupType, "PathSetupType is mandatory."); final PathSetupType pstTlv = (PathSetupType) tlv; Preconditions.checkArgument(checkPST(pstTlv.getPst()), UNSUPPORTED_PST); final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH); body.writeZero(OFFSET); writeUnsignedByte(pstTlv.getPst(), body); TlvUtil.formatTlv(TYPE, body, buffer); }
From source file:org.opendaylight.protocol.pcep.pcecc.PceccLabelObjectParser.java
License:Open Source License
@Override public void serializeObject(final Object object, final ByteBuf buffer) { Preconditions.checkArgument(object instanceof Label, "Wrong instance of PCEPObject. Passed %s . Needed LabelObject.", object.getClass()); final Label lbl = (Label) object; final ByteBuf body = Unpooled.buffer(); body.writeZero(RESERVED); final BitArray flags = new BitArray(FLAGS_SIZE); flags.set(O_FLAG_OFFSET, lbl.isOutLabel()); flags.toByteBuf(body);//from w w w . ja v a 2 s. c o m // body.writeZero(RESERVED_LABEL/Byte.SIZE); final LabelNumber LabelNum = lbl.getLabelNum(); Preconditions.checkArgument(LabelNum != null, "Label Number is mandatory."); writeUnsignedInt(LabelNum.getValue() << MPLS_LABEL_OFFSET, body); serializeTlvs(lbl.getTlvs(), body); ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer); }
From source file:org.opendaylight.protocol.pcep.spi.TlvUtil.java
License:Open Source License
public static void formatTlv(final int type, final ByteBuf body, final ByteBuf out) { out.writeShort(type);// w ww .ja v a 2 s. co m out.writeShort(body.writerIndex()); out.writeBytes(body); out.writeZero(getPadding(HEADER_SIZE + body.writerIndex(), PADDED_TO)); }
From source file:org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROIpv4PrefixSubobjectParser.java
License:Open Source License
@Override public void serializeSubobject(final SubobjectContainer 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 {/*from w ww .j av a2 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); } }
From source file:org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROIpv6PrefixSubobjectParser.java
License:Open Source License
@Override public void serializeSubobject(final SubobjectContainer 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(); final ByteBuf body = Unpooled.buffer(); Preconditions.checkArgument(prefix.getIpv6Prefix() != null, "Ipv6Prefix is mandatory."); writeIpv6Prefix(prefix.getIpv6Prefix(), body); body.writeZero(RESERVED); EROSubobjectUtil.formatSubobject(TYPE, subobject.isLoose(), body, buffer); }
From source file:org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROUnnumberedInterfaceSubobjectParser.java
License:Open Source License
@Override public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) { Preconditions.checkArgument(subobject.getSubobjectType() instanceof UnnumberedCase, "Unknown subobject instance. Passed %s. Needed UnnumberedCase.", subobject.getSubobjectType().getClass()); final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH); body.writeZero(RESERVED); serializeUnnumeredInterface(((UnnumberedCase) subobject.getSubobjectType()).getUnnumbered(), body); EROSubobjectUtil.formatSubobject(TYPE, subobject.isLoose(), body, buffer); }