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.netide.openflowjava.protocol.impl.serialization.factories.MultipartReplyMessageFactory.java

License:Open Source License

private static void writeNextTableRelatedTableProperty(final ByteBuf output,
        final TableFeatureProperties property, final byte code) {
    int startIndex = output.writerIndex();
    output.writeShort(code);/*from  w w  w. j  a  v a 2s  . co m*/
    int lengthIndex = output.writerIndex();
    output.writeShort(EncodeConstants.EMPTY_LENGTH);
    List<NextTableIds> nextTableIds = property.getAugmentation(NextTableRelatedTableFeatureProperty.class)
            .getNextTableIds();
    if (nextTableIds != null) {
        for (NextTableIds next : nextTableIds) {
            output.writeByte(next.getTableId());
        }
    }
    int length = output.writerIndex() - startIndex;
    output.setShort(lengthIndex, length);
    output.writeZero(paddingNeeded(length));
}

From source file:org.opendaylight.netide.openflowjava.protocol.impl.serialization.factories.MultipartReplyMessageFactory.java

License:Open Source License

private void writeInstructionRelatedTableProperty(final ByteBuf output, final TableFeatureProperties property,
        final byte code) {
    int startIndex = output.writerIndex();
    output.writeShort(code);/*  w w w.j av a2 s .c om*/
    int lengthIndex = output.writerIndex();
    output.writeShort(EncodeConstants.EMPTY_LENGTH);
    List<Instruction> instructions = property.getAugmentation(InstructionRelatedTableFeatureProperty.class)
            .getInstruction();
    if (instructions != null) {
        TypeKeyMaker<Instruction> keyMaker = TypeKeyMakerFactory
                .createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID);
        ListSerializer.serializeHeaderList(instructions, keyMaker, registry, output);
    }
    int length = output.writerIndex() - startIndex;
    output.setShort(lengthIndex, length);
    output.writeZero(paddingNeeded(length));
}

From source file:org.opendaylight.netide.openflowjava.protocol.impl.serialization.factories.MultipartReplyMessageFactory.java

License:Open Source License

private void serializeMeterFeaturesBody(MultipartReplyBody body, ByteBuf outBuffer) {
    MultipartReplyMeterFeaturesCase meterFeaturesCase = (MultipartReplyMeterFeaturesCase) body;
    MultipartReplyMeterFeatures meterFeatures = meterFeaturesCase.getMultipartReplyMeterFeatures();
    outBuffer.writeInt(meterFeatures.getMaxMeter().intValue());
    writeBandTypes(meterFeatures.getBandTypes(), outBuffer);
    writeMeterFlags(meterFeatures.getCapabilities(), outBuffer);
    outBuffer.writeByte(meterFeatures.getMaxBands());
    outBuffer.writeByte(meterFeatures.getMaxColor());
    outBuffer.writeZero(METER_FEATURES_PADDING);
}

From source file:org.opendaylight.netide.openflowjava.protocol.impl.serialization.factories.MultipartReplyMessageFactory.java

License:Open Source License

private void serializeMeterBody(MultipartReplyBody body, ByteBuf outBuffer) {
    MultipartReplyMeterCase meterCase = (MultipartReplyMeterCase) body;
    MultipartReplyMeter meter = meterCase.getMultipartReplyMeter();
    for (MeterStats meterStats : meter.getMeterStats()) {
        ByteBuf meterStatsBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
        meterStatsBuff.writeInt(meterStats.getMeterId().getValue().intValue());
        meterStatsBuff.writeInt(EncodeConstants.EMPTY_LENGTH);
        meterStatsBuff.writeZero(METER_PADDING);
        meterStatsBuff.writeInt(meterStats.getFlowCount().intValue());
        meterStatsBuff.writeLong(meterStats.getPacketInCount().longValue());
        meterStatsBuff.writeLong(meterStats.getByteInCount().longValue());
        meterStatsBuff.writeInt(meterStats.getDurationSec().intValue());
        meterStatsBuff.writeInt(meterStats.getDurationNsec().intValue());
        for (MeterBandStats meterBandStats : meterStats.getMeterBandStats()) {
            meterStatsBuff.writeLong(meterBandStats.getPacketBandCount().longValue());
            meterStatsBuff.writeLong(meterBandStats.getByteBandCount().longValue());
        }/*from  www  . j a va  2s . com*/
        meterStatsBuff.setInt(METER_LENGTH_INDEX, meterStatsBuff.readableBytes());
        outBuffer.writeBytes(meterStatsBuff);
    }
}

From source file:org.opendaylight.netide.openflowjava.protocol.impl.serialization.factories.MultipartReplyMessageFactory.java

License:Open Source License

private void serializeGroupDescBody(MultipartReplyBody body, ByteBuf outBuffer, MultipartReplyMessage message) {
    MultipartReplyGroupDescCase groupDescCase = (MultipartReplyGroupDescCase) body;
    MultipartReplyGroupDesc group = groupDescCase.getMultipartReplyGroupDesc();
    for (GroupDesc groupDesc : group.getGroupDesc()) {
        ByteBuf groupDescBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
        groupDescBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
        groupDescBuff.writeByte(groupDesc.getType().getIntValue());
        groupDescBuff.writeZero(GROUP_DESC_PADDING);
        groupDescBuff.writeInt(groupDesc.getGroupId().getValue().intValue());
        for (BucketsList bucket : groupDesc.getBucketsList()) {
            ByteBuf bucketBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
            bucketBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
            bucketBuff.writeShort(bucket.getWeight());
            bucketBuff.writeInt(bucket.getWatchPort().getValue().intValue());
            bucketBuff.writeInt(bucket.getWatchGroup().intValue());
            bucketBuff.writeZero(BUCKET_PADDING);
            ListSerializer.serializeList(bucket.getAction(),
                    TypeKeyMakerFactory.createActionKeyMaker(message.getVersion()), registry, bucketBuff);
            bucketBuff.setShort(BUCKET_LENGTH_INDEX, bucketBuff.readableBytes());
            groupDescBuff.writeBytes(bucketBuff);
        }//w  w w .j a  v  a 2 s.  c o m
        groupDescBuff.setShort(GROUP_DESC_LENGTH_INDEX, groupDescBuff.readableBytes());
        outBuffer.writeBytes(groupDescBuff);
    }
}

From source file:org.opendaylight.netide.openflowjava.protocol.impl.serialization.factories.MultipartReplyMessageFactory.java

License:Open Source License

private void serializeGroupBody(MultipartReplyBody body, ByteBuf outBuffer) {
    MultipartReplyGroupCase groupCase = (MultipartReplyGroupCase) body;
    MultipartReplyGroup group = groupCase.getMultipartReplyGroup();
    for (GroupStats groupStats : group.getGroupStats()) {
        ByteBuf groupStatsBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
        groupStatsBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
        groupStatsBuff.writeZero(GROUP_STATS_PADDING_1);
        groupStatsBuff.writeInt(groupStats.getGroupId().getValue().intValue());
        groupStatsBuff.writeInt(groupStats.getRefCount().intValue());
        groupStatsBuff.writeZero(GROUP_STATS_PADDING_2);
        groupStatsBuff.writeLong(groupStats.getPacketCount().longValue());
        groupStatsBuff.writeLong(groupStats.getByteCount().longValue());
        groupStatsBuff.writeInt(groupStats.getDurationSec().intValue());
        groupStatsBuff.writeInt(groupStats.getDurationNsec().intValue());
        for (BucketStats bucketStats : groupStats.getBucketStats()) {
            groupStatsBuff.writeLong(bucketStats.getPacketCount().longValue());
            groupStatsBuff.writeLong(bucketStats.getByteCount().longValue());
        }/*  w ww  .j  a  v a2  s  .c  o m*/
        groupStatsBuff.setShort(GROUP_STATS_LENGTH_INDEX, groupStatsBuff.readableBytes());
        outBuffer.writeBytes(groupStatsBuff);
    }
}

From source file:org.opendaylight.netide.openflowjava.protocol.impl.serialization.factories.MultipartReplyMessageFactory.java

License:Open Source License

private void serializePortStatsBody(MultipartReplyBody body, ByteBuf outBuffer) {
    MultipartReplyPortStatsCase portStatsCase = (MultipartReplyPortStatsCase) body;
    MultipartReplyPortStats portStats = portStatsCase.getMultipartReplyPortStats();
    for (PortStats portStat : portStats.getPortStats()) {
        outBuffer.writeInt(portStat.getPortNo().intValue());
        outBuffer.writeZero(PORT_STATS_PADDING);
        outBuffer.writeLong(portStat.getRxPackets().longValue());
        outBuffer.writeLong(portStat.getTxPackets().longValue());
        outBuffer.writeLong(portStat.getRxBytes().longValue());
        outBuffer.writeLong(portStat.getTxBytes().longValue());
        outBuffer.writeLong(portStat.getRxDropped().longValue());
        outBuffer.writeLong(portStat.getTxDropped().longValue());
        outBuffer.writeLong(portStat.getRxErrors().longValue());
        outBuffer.writeLong(portStat.getTxErrors().longValue());
        outBuffer.writeLong(portStat.getRxFrameErr().longValue());
        outBuffer.writeLong(portStat.getRxOverErr().longValue());
        outBuffer.writeLong(portStat.getRxCrcErr().longValue());
        outBuffer.writeLong(portStat.getCollisions().longValue());
        outBuffer.writeInt(portStat.getDurationSec().intValue());
        outBuffer.writeInt(portStat.getDurationNsec().intValue());
    }// w w  w .j ava2  s  . co m
}

From source file:org.opendaylight.netide.openflowjava.protocol.impl.serialization.factories.MultipartReplyMessageFactory.java

License:Open Source License

private void serializeTableBody(MultipartReplyBody body, ByteBuf outBuffer) {
    MultipartReplyTableCase tableCase = (MultipartReplyTableCase) body;
    MultipartReplyTable table = tableCase.getMultipartReplyTable();
    for (TableStats tableStats : table.getTableStats()) {
        outBuffer.writeByte(tableStats.getTableId());
        outBuffer.writeZero(TABLE_PADDING);
        outBuffer.writeInt(tableStats.getActiveCount().intValue());
        outBuffer.writeLong(tableStats.getLookupCount().longValue());
        outBuffer.writeLong(tableStats.getMatchedCount().longValue());
    }//w ww  . j av a  2 s  .c  om
}

From source file:org.opendaylight.netide.openflowjava.protocol.impl.serialization.factories.MultipartReplyMessageFactory.java

License:Open Source License

private void serializeAggregateBody(MultipartReplyBody body, ByteBuf outBuffer) {
    MultipartReplyAggregateCase aggregateCase = (MultipartReplyAggregateCase) body;
    MultipartReplyAggregate aggregate = aggregateCase.getMultipartReplyAggregate();
    outBuffer.writeLong(aggregate.getPacketCount().longValue());
    outBuffer.writeLong(aggregate.getByteCount().longValue());
    outBuffer.writeInt(aggregate.getFlowCount().intValue());
    outBuffer.writeZero(AGGREGATE_PADDING);
}

From source file:org.opendaylight.netide.openflowjava.protocol.impl.serialization.factories.MultipartReplyMessageFactory.java

License:Open Source License

private void serializeFlowBody(MultipartReplyBody body, ByteBuf outBuffer, MultipartReplyMessage message) {
    MultipartReplyFlowCase flowCase = (MultipartReplyFlowCase) body;
    MultipartReplyFlow flow = flowCase.getMultipartReplyFlow();
    for (FlowStats flowStats : flow.getFlowStats()) {
        ByteBuf flowStatsBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
        flowStatsBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
        flowStatsBuff.writeByte(new Long(flowStats.getTableId()).byteValue());
        flowStatsBuff.writeZero(FLOW_STATS_PADDING_1);
        flowStatsBuff.writeInt(flowStats.getDurationSec().intValue());
        flowStatsBuff.writeInt(flowStats.getDurationNsec().intValue());
        flowStatsBuff.writeShort(flowStats.getPriority());
        flowStatsBuff.writeShort(flowStats.getIdleTimeout());
        flowStatsBuff.writeShort(flowStats.getHardTimeout());
        flowStatsBuff.writeZero(FLOW_STATS_PADDING_2);
        flowStatsBuff.writeLong(flowStats.getCookie().longValue());
        flowStatsBuff.writeLong(flowStats.getPacketCount().longValue());
        flowStatsBuff.writeLong(flowStats.getByteCount().longValue());
        OFSerializer<Match> matchSerializer = registry.<Match, OFSerializer<Match>>getSerializer(
                new MessageTypeKey<>(message.getVersion(), Match.class));
        matchSerializer.serialize(flowStats.getMatch(), flowStatsBuff);
        ListSerializer.serializeList(flowStats.getInstruction(),
                TypeKeyMakerFactory.createInstructionKeyMaker(message.getVersion()), registry, flowStatsBuff);

        flowStatsBuff.setShort(FLOW_STATS_LENGTH_INDEX, flowStatsBuff.readableBytes());
        outBuffer.writeBytes(flowStatsBuff);
    }/*from   www. j a  va2  s.com*/
}