Example usage for io.netty.buffer ByteBuf skipBytes

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

Introduction

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

Prototype

public abstract ByteBuf skipBytes(int length);

Source Link

Document

Increases the current readerIndex by the specified length in this buffer.

Usage

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.experimenters.ExperimenterActionDeserializer.java

License:Open Source License

@Override
public Action deserializeHeader(ByteBuf input) {
    ActionBuilder builder = new ActionBuilder();
    input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    builder.setType(Experimenter.class);
    input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder();
    expBuilder.setExperimenter(input.readUnsignedInt());
    builder.addAugmentation(ExperimenterAction.class, expBuilder.build());
    return builder.build();
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.experimenters.ExperimenterActionDeserializer.java

License:Open Source License

@Override
public Action deserialize(ByteBuf input) {
    ActionBuilder builder = new ActionBuilder();
    input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    builder.setType(Experimenter.class);
    int length = input.readUnsignedShort();
    // subtract experimenter header length
    length -= EncodeConstants.EXPERIMENTER_IDS_LENGTH;
    ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder();
    expBuilder.setExperimenter(input.readUnsignedInt());
    if (length > 0) {
        byte[] data = new byte[length];
        input.readBytes(data);/*  ww w .j  av  a  2 s  . co m*/
        expBuilder.setData(data);
    }
    builder.addAugmentation(ExperimenterAction.class, expBuilder.build());
    return builder.build();
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.experimenters.OF13ExperimenterInstructionDeserializer.java

License:Open Source License

@Override
public Instruction deserializeHeader(ByteBuf input) {
    InstructionBuilder builder = new InstructionBuilder();
    input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    builder.setType(Experimenter.class);
    input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder();
    expBuilder.setExperimenter(input.readUnsignedInt());
    return builder.build();
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.experimenters.OF13ExperimenterInstructionDeserializer.java

License:Open Source License

@Override
public Instruction deserialize(ByteBuf input) {
    InstructionBuilder builder = new InstructionBuilder();
    input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    builder.setType(Experimenter.class);
    input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder();
    expBuilder.setExperimenter(input.readUnsignedInt());
    if (input.readableBytes() > 0) {
        byte[] data = new byte[input.readableBytes()];
        input.readBytes(data);//from w w w. j av  a 2 s .  c  om
        expBuilder.setData(data);
    }
    builder.addAugmentation(ExperimenterInstruction.class, expBuilder.build());
    return builder.build();
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FeaturesReplyMessageFactory.java

License:Open Source License

@Override
public GetFeaturesOutput bufferToMessage(ByteBuf rawMessage, short version) {
    GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder();
    builder.setVersion(version);/* www . ja va  2  s .  co m*/
    builder.setXid(rawMessage.readUnsignedInt());
    byte[] datapathId = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    rawMessage.readBytes(datapathId);
    builder.setDatapathId(new BigInteger(1, datapathId));
    builder.setBuffers(rawMessage.readUnsignedInt());
    builder.setTables(rawMessage.readUnsignedByte());
    builder.setAuxiliaryId(rawMessage.readUnsignedByte());
    rawMessage.skipBytes(PADDING_IN_FEATURES_REPLY_HEADER);
    builder.setCapabilities(createCapabilities(rawMessage.readUnsignedInt()));
    builder.setReserved(rawMessage.readUnsignedInt());
    return builder.build();
}

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

License:Open Source License

@Override
public MultipartReplyMessage bufferToMessage(ByteBuf rawMessage, short version) {
    MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
    builder.setVersion(version);/*from   w  w  w .j av a2 s . co m*/
    builder.setXid(rawMessage.readUnsignedInt());
    int type = rawMessage.readUnsignedShort();
    builder.setType(MultipartType.forValue(type));
    builder.setFlags(new MultipartRequestFlags((rawMessage.readUnsignedShort() & 0x01) != 0));
    rawMessage.skipBytes(PADDING_IN_MULTIPART_REPLY_HEADER);

    switch (type) {
    case 0:
        builder.setMultipartReplyBody(setDesc(rawMessage));
        break;
    case 1:
        builder.setMultipartReplyBody(setFlow(rawMessage));
        break;
    case 2:
        builder.setMultipartReplyBody(setAggregate(rawMessage));
        break;
    case 3:
        builder.setMultipartReplyBody(setTable(rawMessage));
        break;
    case 4:
        builder.setMultipartReplyBody(setPortStats(rawMessage));
        break;
    case 5:
        builder.setMultipartReplyBody(setQueue(rawMessage));
        break;
    case 6:
        builder.setMultipartReplyBody(setGroup(rawMessage));
        break;
    case 7:
        builder.setMultipartReplyBody(setGroupDesc(rawMessage));
        break;
    case 8:
        builder.setMultipartReplyBody(setGroupFeatures(rawMessage));
        break;
    case 9:
        builder.setMultipartReplyBody(setMeter(rawMessage));
        break;
    case 10:
        builder.setMultipartReplyBody(setMeterConfig(rawMessage));
        break;
    case 11:
        builder.setMultipartReplyBody(setMeterFeatures(rawMessage));
        break;
    case 12:
        builder.setMultipartReplyBody(setTableFeatures(rawMessage));
        break;
    case 13:
        builder.setMultipartReplyBody(setPortDesc(rawMessage));
        break;
    case 0xFFFF:
        builder.setMultipartReplyBody(setExperimenter(rawMessage));
        break;
    default:
        break;
    }

    return builder.build();
}

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

License:Open Source License

private static MultipartReplyFlowCase setFlow(ByteBuf input) {
    MultipartReplyFlowCaseBuilder caseBuilder = new MultipartReplyFlowCaseBuilder();
    MultipartReplyFlowBuilder flowBuilder = new MultipartReplyFlowBuilder();
    List<FlowStats> flowStatsList = new ArrayList<>();
    while (input.readableBytes() > 0) {
        FlowStatsBuilder flowStatsBuilder = new FlowStatsBuilder();
        int flowRecordLength = input.readUnsignedShort();
        ByteBuf subInput = input.readSlice(flowRecordLength - EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
        flowStatsBuilder.setTableId(subInput.readUnsignedByte());
        subInput.skipBytes(PADDING_IN_FLOW_STATS_HEADER_01);
        flowStatsBuilder.setDurationSec(subInput.readUnsignedInt());
        flowStatsBuilder.setDurationNsec(subInput.readUnsignedInt());
        flowStatsBuilder.setPriority(subInput.readUnsignedShort());
        flowStatsBuilder.setIdleTimeout(subInput.readUnsignedShort());
        flowStatsBuilder.setHardTimeout(subInput.readUnsignedShort());
        flowStatsBuilder.setFlags(createFlowModFlagsFromBitmap(subInput.readUnsignedShort()));
        subInput.skipBytes(PADDING_IN_FLOW_STATS_HEADER_02);
        byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        subInput.readBytes(cookie);/*from  ww  w  .  j  av a2  s.  c  o  m*/
        flowStatsBuilder.setCookie(new BigInteger(1, cookie));
        byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        subInput.readBytes(packetCount);
        flowStatsBuilder.setPacketCount(new BigInteger(1, packetCount));
        byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        subInput.readBytes(byteCount);
        flowStatsBuilder.setByteCount(new BigInteger(1, byteCount));
        flowStatsBuilder.setMatch(MatchDeserializer.createMatch(subInput));
        flowStatsBuilder.setInstruction(
                InstructionsDeserializer.createInstructions(subInput, subInput.readableBytes()));
        flowStatsList.add(flowStatsBuilder.build());
    }
    flowBuilder.setFlowStats(flowStatsList);
    caseBuilder.setMultipartReplyFlow(flowBuilder.build());
    return caseBuilder.build();
}

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

License:Open Source License

private static MultipartReplyAggregateCase setAggregate(ByteBuf input) {
    MultipartReplyAggregateCaseBuilder caseBuilder = new MultipartReplyAggregateCaseBuilder();
    MultipartReplyAggregateBuilder builder = new MultipartReplyAggregateBuilder();
    byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    input.readBytes(packetCount);//from   w ww. j  a v  a 2s .  c  om
    builder.setPacketCount(new BigInteger(1, packetCount));
    byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    input.readBytes(byteCount);
    builder.setByteCount(new BigInteger(1, byteCount));
    builder.setFlowCount(input.readUnsignedInt());
    input.skipBytes(PADDING_IN_AGGREGATE_HEADER);
    caseBuilder.setMultipartReplyAggregate(builder.build());
    return caseBuilder.build();
}

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

License:Open Source License

private static MultipartReplyTableCase setTable(ByteBuf input) {
    MultipartReplyTableCaseBuilder caseBuilder = new MultipartReplyTableCaseBuilder();
    MultipartReplyTableBuilder builder = new MultipartReplyTableBuilder();
    List<TableStats> tableStatsList = new ArrayList<>();
    while (input.readableBytes() > 0) {
        TableStatsBuilder tableStatsBuilder = new TableStatsBuilder();
        tableStatsBuilder.setTableId(input.readUnsignedByte());
        input.skipBytes(PADDING_IN_TABLE_HEADER);
        tableStatsBuilder.setActiveCount(input.readUnsignedInt());
        byte[] lookupCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(lookupCount);/*w  w w . j  a  v a  2s  . co  m*/
        tableStatsBuilder.setLookupCount(new BigInteger(1, lookupCount));
        byte[] matchedCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(matchedCount);
        tableStatsBuilder.setMatchedCount(new BigInteger(1, matchedCount));
        tableStatsList.add(tableStatsBuilder.build());
    }
    builder.setTableStats(tableStatsList);
    caseBuilder.setMultipartReplyTable(builder.build());
    return caseBuilder.build();
}

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

License:Open Source License

private static MultipartReplyTableFeaturesCase setTableFeatures(ByteBuf input) {
    MultipartReplyTableFeaturesCaseBuilder caseBuilder = new MultipartReplyTableFeaturesCaseBuilder();
    MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();
    List<TableFeatures> features = new ArrayList<>();
    while (input.readableBytes() > 0) {
        TableFeaturesBuilder featuresBuilder = new TableFeaturesBuilder();
        int length = input.readUnsignedShort();
        featuresBuilder.setTableId(input.readUnsignedByte());
        input.skipBytes(PADDING_IN_MULTIPART_REPLY_TABLE_FEATURES);
        featuresBuilder.setName(input.readBytes(MAX_TABLE_NAME_LENGTH).toString());
        byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(metadataMatch);/* w w  w .j a v  a2s. c o  m*/
        featuresBuilder.setMetadataMatch(metadataMatch);
        byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(metadataWrite);
        featuresBuilder.setMetadataWrite(metadataWrite);
        featuresBuilder.setConfig(createTableConfig(input.readUnsignedInt()));
        featuresBuilder.setMaxEntries(input.readUnsignedInt());
        featuresBuilder.setTableFeatureProperties(
                createTableFeaturesProperties(input, length - MULTIPART_REPLY_TABLE_FEATURES_STRUCTURE_LENGTH));
        features.add(featuresBuilder.build());
    }
    builder.setTableFeatures(features);
    caseBuilder.setMultipartReplyTableFeatures(builder.build());
    return caseBuilder.build();
}