Example usage for io.netty.buffer ByteBuf readUnsignedInt

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

Introduction

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

Prototype

public abstract long readUnsignedInt();

Source Link

Document

Gets an unsigned 32-bit integer at the current readerIndex and increases the readerIndex by 4 in this buffer.

Usage

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

License:Open Source License

@Override
public ExperimenterMessage bufferToMessage(ByteBuf rawMessage, short version) {
    ExperimenterMessageBuilder builder = new ExperimenterMessageBuilder();
    builder.setVersion(version);/*  ww w  .  j a v  a 2 s  .  co  m*/
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setExperimenter(rawMessage.readUnsignedInt());
    builder.setExpType(rawMessage.readUnsignedInt());
    int remainingBytes = rawMessage.readableBytes();
    if (remainingBytes > 0) {
        builder.setData(rawMessage.readBytes(remainingBytes).array());
    }
    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);//from   w  w w.  j a va 2 s.c o  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.FlowRemovedMessageFactory.java

License:Open Source License

@Override
public FlowRemovedMessage bufferToMessage(ByteBuf rawMessage, short version) {
    FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder();
    builder.setVersion(version);//from   w  w w .  j ava  2  s. co m
    builder.setXid(rawMessage.readUnsignedInt());
    byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    rawMessage.readBytes(cookie);
    builder.setCookie(new BigInteger(1, cookie));
    builder.setPriority(rawMessage.readUnsignedShort());
    builder.setReason(FlowRemovedReason.forValue(rawMessage.readUnsignedByte()));
    builder.setTableId(new TableId((long) rawMessage.readUnsignedByte()));
    builder.setDurationSec(rawMessage.readUnsignedInt());
    builder.setDurationNsec(rawMessage.readUnsignedInt());
    builder.setIdleTimeout(rawMessage.readUnsignedShort());
    builder.setHardTimeout(rawMessage.readUnsignedShort());
    byte[] packet_count = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    rawMessage.readBytes(packet_count);
    builder.setPacketCount(new BigInteger(1, packet_count));
    byte[] byte_count = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    rawMessage.readBytes(byte_count);
    builder.setByteCount(new BigInteger(1, byte_count));
    builder.setMatch(MatchDeserializer.createMatch(rawMessage));
    return builder.build();
}

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

License:Open Source License

@Override
public GetAsyncOutput bufferToMessage(ByteBuf rawMessage, short version) {
    GetAsyncOutputBuilder builder = new GetAsyncOutputBuilder();
    builder.setVersion(version);/*from  ww w.  j ava2  s.co m*/
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setPacketInMask(decodePacketInMask(rawMessage));
    builder.setPortStatusMask(decodePortStatusMask(rawMessage));
    builder.setFlowRemovedMask(decodeFlowRemovedMask(rawMessage));
    return builder.build();
}

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

License:Open Source License

@Override
public GetConfigInput deserialize(ByteBuf rawMessage) {
    GetConfigInputBuilder builder = new GetConfigInputBuilder();
    builder.setVersion(getVersion());//  w  w  w  .  j  a  v  a2s .  c o m
    builder.setXid(rawMessage.readUnsignedInt());
    return builder.build();
}

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

License:Open Source License

@Override
public GetConfigOutput bufferToMessage(ByteBuf rawMessage, short version) {
    GetConfigOutputBuilder builder = new GetConfigOutputBuilder();
    builder.setVersion(version);/*from  www.j  a  v a2s . c o  m*/
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setFlags(SwitchConfigFlag.forValue(rawMessage.readUnsignedShort()));
    builder.setMissSendLen(rawMessage.readUnsignedShort());
    return builder.build();
}

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

License:Open Source License

@Override
public HelloMessage bufferToMessage(ByteBuf rawMessage, short version) {
    HelloMessageBuilder builder = new HelloMessageBuilder();
    builder.setVersion(version);/*from w  w w . jav a 2 s. co m*/
    builder.setXid(rawMessage.readUnsignedInt());
    if (rawMessage.readableBytes() > 0) {
        builder.setElements(readElement(rawMessage));
    }
    return builder.build();
}

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

License:Open Source License

private static List<Elements> readElement(ByteBuf input) {
    List<Elements> elementsList = new ArrayList<>();
    while (input.readableBytes() > 0) {
        ElementsBuilder elementsBuilder = new ElementsBuilder();
        int type = input.readUnsignedShort();
        int elementLength = input.readUnsignedShort();
        if (type == HelloElementType.VERSIONBITMAP.getIntValue()) {
            elementsBuilder.setType(HelloElementType.forValue(type));
            int[] versionBitmap = new int[(elementLength - HelloInputMessageFactory.HELLO_ELEMENT_HEADER_SIZE)
                    / 4];/*from   w  w  w .j a v a2 s.  co  m*/
            for (int i = 0; i < versionBitmap.length; i++) {
                versionBitmap[i] = (int) input.readUnsignedInt();
            }
            elementsBuilder.setVersionBitmap(readVersionBitmap(versionBitmap));
            int paddingRemainder = elementLength % EncodeConstants.PADDING;
            if (paddingRemainder != 0) {
                input.readBytes(EncodeConstants.PADDING - paddingRemainder);
            }
        }
        elementsList.add(elementsBuilder.build());
    }
    return elementsList;
}

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  a  va  2 s.c o  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);/*  w  w w.ja  va 2 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();
}