Example usage for io.netty.buffer ByteBuf writeZero

List of usage examples for io.netty.buffer ByteBuf writeZero

Introduction

In this page you can find the example usage for io.netty.buffer ByteBuf writeZero.

Prototype

public abstract ByteBuf writeZero(int length);

Source Link

Document

Fills this buffer with NUL (0x00) starting at the current writerIndex and increases the writerIndex by the specified length .

Usage

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.instruction.ClearActionsInstructionSerializer.java

License:Open Source License

@Override
public void serialize(final Instruction instruction, final ByteBuf outBuffer) {
    outBuffer.writeShort(getType());/*from w  w  w. ja va  2 s . c  o m*/
    outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH);
    outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.instruction.GoToTableInstructionSerializer.java

License:Open Source License

@Override
public void serialize(Instruction instruction, ByteBuf outBuffer) {
    outBuffer.writeShort(getType());/*from  w w w  .jav  a2  s.  c  om*/
    outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH);
    outBuffer.writeByte(((GotoTableCase) instruction.getInstructionChoice()).getGotoTable().getTableId());
    outBuffer.writeZero(InstructionConstants.PADDING_IN_GOTO_TABLE);
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.instruction.WriteActionsInstructionSerializer.java

License:Open Source License

@Override
public void serialize(final Instruction instruction, final ByteBuf outBuffer) {
    int startIndex = outBuffer.writerIndex();
    outBuffer.writeShort(getType());//from  w  ww. j  a  va2 s .  c om
    WriteActionsCase actionsCase = (WriteActionsCase) instruction.getInstructionChoice();
    if (actionsCase != null) {
        List<Action> actions = actionsCase.getWriteActions().getAction();
        writeActions(actions, outBuffer, startIndex);
    } else {
        outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH);
        outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
    }
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.instruction.WriteMetadataInstructionSerializer.java

License:Open Source License

@Override
public void serialize(Instruction instruction, ByteBuf outBuffer) {
    outBuffer.writeShort(getType());//from   ww  w.j  av a  2s  .c  om
    outBuffer.writeShort(InstructionConstants.WRITE_METADATA_LENGTH);
    outBuffer.writeZero(InstructionConstants.PADDING_IN_WRITE_METADATA);
    WriteMetadata metadata = ((WriteMetadataCase) instruction.getInstructionChoice()).getWriteMetadata();
    outBuffer.writeBytes(metadata.getMetadata());
    outBuffer.writeBytes(metadata.getMetadataMask());
}

From source file:org.opendaylight.openflowjava.protocol.impl.util.OF13MatchSerializer.java

License:Open Source License

@Override
public void serialize(Match match, ByteBuf outBuffer) {
    if (match == null) {
        LOG.debug("Match is null");
        return;//from   w  w  w. j  a  v a 2 s  .  c o  m
    }
    int matchStartIndex = outBuffer.writerIndex();
    serializeType(match, outBuffer);
    int matchLengthIndex = outBuffer.writerIndex();
    outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH);
    serializeMatchEntries(match.getMatchEntry(), outBuffer);
    // Length of ofp_match (excluding padding)
    int matchLength = outBuffer.writerIndex() - matchStartIndex;
    outBuffer.setShort(matchLengthIndex, matchLength);
    int paddingRemainder = matchLength % EncodeConstants.PADDING;
    if (paddingRemainder != 0) {
        outBuffer.writeZero(EncodeConstants.PADDING - paddingRemainder);
    }
}

From source file:org.opendaylight.openflowjava.util.ByteBufUtils.java

License:Open Source License

/**
 * Fills specified ByteBuf with 0 (zeros) of desired length, used for padding
 * @param length/*from   www  .  j  a v  a2 s .  com*/
 * @param out ByteBuf to be padded
 * @deprecated Use {@link ByteBuf#writeZero(int)} directly.
 */
@Deprecated
public static void padBuffer(final int length, final ByteBuf out) {
    out.writeZero(length);
}

From source file:org.opendaylight.protocol.bgp.evpn.impl.attributes.PMSITunnelAttributeHandler.java

License:Open Source License

private void serializeMpls(final MplsLabel mplsLabel, final ByteBuf body) {
    if (mplsLabel == null) {
        body.writeZero(MPLS_LENGTH);
    }/* w  ww .j ava2s. c  o  m*/
    body.writeBytes(MplsLabelUtil.byteBufForMplsLabel(mplsLabel));
}

From source file:org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.RsvpTeP2MpLspParser.java

License:Open Source License

@Override
public int serialize(final TunnelIdentifier tunnelIdentifier, final ByteBuf buffer) {
    Preconditions.checkArgument(tunnelIdentifier instanceof RsvpTeP2mpLsp,
            "The tunnelIdentifier %s is not RsvpTeP2mpLps type.", tunnelIdentifier);
    final RsvpTeP2mpLps rsvpTeP2mpLsp = ((RsvpTeP2mpLsp) tunnelIdentifier).getRsvpTeP2mpLps();
    ByteBufWriteUtil.writeUnsignedInt(rsvpTeP2mpLsp.getP2mpId(), buffer);
    buffer.writeZero(RESERVED);
    ByteBufWriteUtil.writeUnsignedShort(rsvpTeP2mpLsp.getTunnelId(), buffer);
    serializeIpAddress(rsvpTeP2mpLsp.getExtendedTunnelId(), buffer);
    return TunnelType.RSVP_TE_P2MP_LSP.getIntValue();
}

From source file:org.opendaylight.protocol.bgp.evpn.impl.esi.types.ASGenParser.java

License:Open Source License

@Override
public void serializeBody(final Esi esi, final ByteBuf body) {
    Preconditions.checkArgument(esi instanceof AsGeneratedCase,
            "Unknown esi instance. Passed %s. Needed AsGeneratedCase.", esi.getClass());
    final AsGenerated asGen = ((AsGeneratedCase) esi).getAsGenerated();
    writeUnsignedInt(asGen.getAs().getValue(), body);
    writeUnsignedInt(asGen.getLocalDiscriminator(), body);
    body.writeZero(ZERO_BYTE);
}

From source file:org.opendaylight.protocol.bgp.evpn.impl.esi.types.LacpParser.java

License:Open Source License

@Override
public void serializeBody(final Esi esi, final ByteBuf body) {
    Preconditions.checkArgument(esi instanceof LacpAutoGeneratedCase,
            "Unknown esi instance. Passed %s. Needed LacpAutoGeneratedCase.", esi.getClass());
    final LacpAutoGenerated lacp = ((LacpAutoGeneratedCase) esi).getLacpAutoGenerated();
    body.writeBytes(IetfYangUtil.INSTANCE.bytesFor(lacp.getCeLacpMacAddress()));
    ByteBufWriteUtil.writeUnsignedShort(lacp.getCeLacpPortKey(), body);
    body.writeZero(ZERO_BYTE);
}