List of usage examples for io.netty.buffer ByteBuf writeZero
public abstract ByteBuf writeZero(int length);
From source file:org.opendaylight.protocol.bgp.linkstate.attribute.sr.SrPrefixAttributesParser.java
License:Open Source License
public static void serializePrefixAttributes(final Flags flags, final Algorithm algorithm, final SidLabelIndex sidLabelIndex, final ByteBuf buffer) { final BitArray bitFlags = serializePrefixFlags(flags, sidLabelIndex); bitFlags.toByteBuf(buffer);/*from www .ja va 2 s . c o m*/ buffer.writeByte(algorithm.getIntValue()); buffer.writeZero(RESERVED_PREFIX); buffer.writeBytes(SidLabelIndexParser.serializeSidValue(sidLabelIndex)); }
From source file:org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.binding.sid.sub.tlvs.Ipv4EroParser.java
License:Open Source License
static void serializeEroFlags(final ByteBuf buffer, final Boolean loose) { final BitArray flags = new BitArray(FLAGS_SIZE); flags.set(LOOSE, loose);//w ww. j a va 2 s .co m flags.toByteBuf(buffer); buffer.writeZero(RESERVED_ERO); }
From source file:org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.BindingSidLabelParser.java
License:Open Source License
public static void serializeBindingSidAttributes(final Weight weight, final Flags flags, final List<BindingSubTlvs> bindingSubTlvs, final ByteBuf aggregator) { aggregator.writeByte(weight.getValue()); final BitArray bitFlags = serializeBindingSidFlags(flags); bitFlags.toByteBuf(aggregator);/*from w ww.java2 s.co m*/ aggregator.writeZero(RESERVED_BINDING_SID); SimpleBindingSubTlvsRegistry.getInstance().serializeBindingSubTlvs(bindingSubTlvs, aggregator); }
From source file:org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.Ipv6SrPrefixAttributesParser.java
License:Open Source License
public static void serializePrefixAttributes(final Algorithm algorithm, final ByteBuf buffer) { buffer.writeZero(FLAGS_SIZE); buffer.writeByte(algorithm.getIntValue()); }
From source file:org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.SrLinkAttributesParser.java
License:Open Source License
public static <T extends EpeAdjSidTlv> ByteBuf serializeAdjacencySegmentIdentifier(final T adjSid) { final ByteBuf value = Unpooled.buffer(); if (adjSid instanceof SrAdjIds) { final BitArray flags = serializeAdjFlags(((SrAdjIds) adjSid).getFlags(), adjSid.getSidLabelIndex()); flags.toByteBuf(value);/*from w w w . j a v a 2 s .c om*/ } else { value.writeZero(FLAGS_BYTE_SIZE); } value.writeByte(adjSid.getWeight().getValue()); value.writeZero(RESERVED); value.writeBytes(SidLabelIndexParser.serializeSidValue(adjSid.getSidLabelIndex())); return value; }
From source file:org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.SrNodeAttributesParser.java
License:Open Source License
public static void serializeSrCapabilities(final SrCapabilities caps, final ByteBuf buffer) { final BitArray bs = new BitArray(FLAGS_SIZE); bs.set(MPLS_IPV4, caps.isMplsIpv4()); bs.set(MPLS_IPV6, caps.isMplsIpv6()); bs.set(SR_IPV6, caps.isSrIpv6());//from w w w .j a v a 2 s. c o m bs.toByteBuf(buffer); buffer.writeZero(RESERVERED); buffer.writeMedium(caps.getRangeSize().intValue()); TlvUtil.writeTLV(SID_TYPE, SidLabelIndexParser.serializeSidValue(caps.getSidLabelIndex()), buffer); }
From source file:org.opendaylight.protocol.bgp.parser.impl.message.BGPUpdateMessageParser.java
License:Open Source License
@Override public void serializeMessage(final Notification message, final ByteBuf bytes) { Preconditions.checkArgument(message instanceof Update, "Message needs to be of type Update"); final Update update = (Update) message; final ByteBuf messageBody = Unpooled.buffer(); final WithdrawnRoutes withdrawnRoutes = update.getWithdrawnRoutes(); if (withdrawnRoutes != null) { final ByteBuf withdrawnRoutesBuf = Unpooled.buffer(); for (final Ipv4Prefix prefix : withdrawnRoutes.getWithdrawnRoutes()) { ByteBufWriteUtil.writeMinimalPrefix(prefix, withdrawnRoutesBuf); }/*from w w w . j a va 2 s . c om*/ messageBody.writeShort(withdrawnRoutesBuf.writerIndex()); messageBody.writeBytes(withdrawnRoutesBuf); } else { messageBody.writeZero(WITHDRAWN_ROUTES_LENGTH_SIZE); } if (update.getAttributes() != null) { final ByteBuf pathAttributesBuf = Unpooled.buffer(); this.reg.serializeAttribute(update.getAttributes(), pathAttributesBuf); messageBody.writeShort(pathAttributesBuf.writerIndex()); messageBody.writeBytes(pathAttributesBuf); } else { messageBody.writeZero(TOTAL_PATH_ATTR_LENGTH_SIZE); } final Nlri nlri = update.getNlri(); if (nlri != null && nlri.getNlri() != null) { for (final Ipv4Prefix prefix : nlri.getNlri()) { ByteBufWriteUtil.writeMinimalPrefix(prefix, messageBody); } } MessageUtil.formatMessage(TYPE, messageBody, bytes); }
From source file:org.opendaylight.protocol.bgp.parser.impl.message.open.GracefulCapabilityHandler.java
License:Open Source License
private void serializeTables(final List<Tables> tables, final ByteBuf bytes) { if (tables == null) { return;//from w ww . java 2 s .c o m } for (final Tables t : tables) { final Class<? extends AddressFamily> afi = t.getAfi(); final Integer afival = this.afiReg.numberForClass(afi); Preconditions.checkArgument(afival != null, "Unhandled address family " + afi); bytes.writeShort(afival); final Class<? extends SubsequentAddressFamily> safi = t.getSafi(); final Integer safival = this.safiReg.numberForClass(safi); Preconditions.checkArgument(safival != null, "Unhandled subsequent address family " + safi); bytes.writeByte(safival); if (t.getAfiFlags() != null && t.getAfiFlags().isForwardingState()) { bytes.writeByte(AFI_FLAG_FORWARDING_STATE); } else { bytes.writeZero(1); } } }
From source file:org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.EncapsulationEC.java
License:Open Source License
@Override public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf body) { Preconditions.checkArgument(extendedCommunity instanceof EncapsulationCase, "The extended community %s is not EncapsulationCase type.", extendedCommunity); final EncapsulationExtendedCommunity encap = ((EncapsulationCase) extendedCommunity) .getEncapsulationExtendedCommunity(); body.writeZero(RESERVED_SIZE); body.writeShort(encap.getTunnelType().getIntValue()); }
From source file:org.opendaylight.protocol.bgp.parser.spi.MultiprotocolCapabilitiesUtil.java
License:Open Source License
public static void serializeMPAfiSafi(final AddressFamilyRegistry afiReg, final SubsequentAddressFamilyRegistry safiReg, final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi, final ByteBuf capBuffer) { final Integer afival = afiReg.numberForClass(afi); Preconditions.checkArgument(afival != null, "Unhandled address family " + afi); capBuffer.writeShort(afival);/*from w ww. ja v a2 s . c o m*/ capBuffer.writeZero(RESERVED); final Integer safival = safiReg.numberForClass(safi); Preconditions.checkArgument(safival != null, "Unhandled subsequent address family " + safi); capBuffer.writeByte(safival); }