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.MultipartReplyMessageFactory.java

License:Open Source License

private static MultipartReplyExperimenterCase setExperimenter(ByteBuf input) {
    MultipartReplyExperimenterCaseBuilder caseBuilder = new MultipartReplyExperimenterCaseBuilder();
    MultipartReplyExperimenterBuilder builder = new MultipartReplyExperimenterBuilder();
    builder.setExperimenter(input.readUnsignedInt());
    builder.setExpType(input.readUnsignedInt());
    byte[] data = new byte[input.readableBytes()];
    input.readBytes(data);/*from   w  w  w. j a  v  a 2 s  .co m*/
    builder.setData(data);
    caseBuilder.setMultipartReplyExperimenter(builder.build());
    return caseBuilder.build();
}

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

License:Open Source License

private static MultipartReplyPortDescCase setPortDesc(ByteBuf input) {
    MultipartReplyPortDescCaseBuilder caseBuilder = new MultipartReplyPortDescCaseBuilder();
    MultipartReplyPortDescBuilder builder = new MultipartReplyPortDescBuilder();
    List<Ports> portsList = new ArrayList<>();
    while (input.readableBytes() > 0) {
        PortsBuilder portsBuilder = new PortsBuilder();
        portsBuilder.setPortNo(input.readUnsignedInt());
        input.skipBytes(PADDING_IN_PORT_DESC_HEADER_01);
        byte[] hwAddress = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
        input.readBytes(hwAddress);//from www  .  ja  va 2  s . c  o  m
        portsBuilder.setHwAddr(new MacAddress(ByteBufUtils.macAddressToString(hwAddress)));
        input.skipBytes(PADDING_IN_PORT_DESC_HEADER_02);
        portsBuilder
                .setName(ByteBufUtils.decodeNullTerminatedString(input, EncodeConstants.MAX_PORT_NAME_LENGTH));
        portsBuilder.setConfig(createPortConfig(input.readUnsignedInt()));
        portsBuilder.setState(createPortState(input.readUnsignedInt()));
        portsBuilder.setCurrentFeatures(createPortFeatures(input.readUnsignedInt()));
        portsBuilder.setAdvertisedFeatures(createPortFeatures(input.readUnsignedInt()));
        portsBuilder.setSupportedFeatures(createPortFeatures(input.readUnsignedInt()));
        portsBuilder.setPeerFeatures(createPortFeatures(input.readUnsignedInt()));
        portsBuilder.setCurrSpeed(input.readUnsignedInt());
        portsBuilder.setMaxSpeed(input.readUnsignedInt());
        portsList.add(portsBuilder.build());
    }
    builder.setPorts(portsList);
    caseBuilder.setMultipartReplyPortDesc(builder.build());
    return caseBuilder.build();
}

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

License:Open Source License

private static MultipartReplyGroupFeaturesCase setGroupFeatures(ByteBuf rawMessage) {
    MultipartReplyGroupFeaturesCaseBuilder caseBuilder = new MultipartReplyGroupFeaturesCaseBuilder();
    MultipartReplyGroupFeaturesBuilder featuresBuilder = new MultipartReplyGroupFeaturesBuilder();
    featuresBuilder.setTypes(createGroupType(rawMessage.readUnsignedInt()));
    featuresBuilder.setCapabilities(createCapabilities(rawMessage.readUnsignedInt()));
    List<Long> maxGroupsList = new ArrayList<>();
    for (int i = 0; i < GROUP_TYPES; i++) {
        maxGroupsList.add(rawMessage.readUnsignedInt());
    }//from ww w. java  2  s  .  c o  m
    featuresBuilder.setMaxGroups(maxGroupsList);
    List<ActionType> actionBitmaps = new ArrayList<>();
    for (int i = 0; i < GROUP_TYPES; i++) {
        actionBitmaps.add(createActionBitmap(rawMessage.readUnsignedInt()));
    }
    featuresBuilder.setActionsBitmap(actionBitmaps);
    caseBuilder.setMultipartReplyGroupFeatures(featuresBuilder.build());
    return caseBuilder.build();
}

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

License:Open Source License

private static MultipartReplyGroupDescCase setGroupDesc(ByteBuf input) {
    MultipartReplyGroupDescCaseBuilder caseBuilder = new MultipartReplyGroupDescCaseBuilder();
    MultipartReplyGroupDescBuilder builder = new MultipartReplyGroupDescBuilder();
    List<GroupDesc> groupDescsList = new ArrayList<>();
    while (input.readableBytes() > 0) {
        GroupDescBuilder groupDescBuilder = new GroupDescBuilder();
        int bodyLength = input.readUnsignedShort();
        groupDescBuilder.setType(GroupType.forValue(input.readUnsignedByte()));
        input.skipBytes(PADDING_IN_GROUP_DESC_HEADER);
        groupDescBuilder.setGroupId(new GroupId(input.readUnsignedInt()));
        int actualLength = GROUP_DESC_HEADER_LENGTH;
        List<BucketsList> bucketsList = new ArrayList<>();
        while (actualLength < bodyLength) {
            BucketsListBuilder bucketsBuilder = new BucketsListBuilder();
            int bucketsLength = input.readUnsignedShort();
            bucketsBuilder.setWeight(input.readUnsignedShort());
            bucketsBuilder.setWatchPort(new PortNumber(input.readUnsignedInt()));
            bucketsBuilder.setWatchGroup(input.readUnsignedInt());
            input.skipBytes(PADDING_IN_BUCKETS_HEADER);
            List<Action> actionsList = ActionsDeserializer.createActions(input,
                    bucketsLength - BUCKETS_HEADER_LENGTH);
            bucketsBuilder.setAction(actionsList);
            bucketsList.add(bucketsBuilder.build());
            actualLength += bucketsLength;
        }//from ww w.ja v a  2s. c  o  m
        groupDescBuilder.setBucketsList(bucketsList);
        groupDescsList.add(groupDescBuilder.build());
    }
    builder.setGroupDesc(groupDescsList);
    caseBuilder.setMultipartReplyGroupDesc(builder.build());
    return caseBuilder.build();
}

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

License:Open Source License

@Override
public BarrierOutput deserialize(ByteBuf rawMessage) {
    BarrierOutputBuilder builder = new BarrierOutputBuilder();
    builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    return builder.build();
}

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

License:Open Source License

@Override
public EchoOutput deserialize(ByteBuf rawMessage) {
    EchoOutputBuilder builder = new EchoOutputBuilder();
    builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    int remainingBytes = rawMessage.readableBytes();
    if (remainingBytes > 0) {
        builder.setData(rawMessage.readBytes(remainingBytes).array());
    }//from   w  ww .  j  a va2s  .  c om
    return builder.build();
}

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

License:Open Source License

@Override
public EchoRequestMessage deserialize(ByteBuf rawMessage) {
    EchoRequestMessageBuilder builder = new EchoRequestMessageBuilder();
    builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array());
    return builder.build();
}

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

License:Open Source License

@Override
public ErrorMessage bufferToMessage(ByteBuf rawMessage, short version) {
    ErrorMessageBuilder builder = new ErrorMessageBuilder();
    builder.setVersion(version);/*from ww  w  .  ja va2s .  co m*/
    builder.setXid(rawMessage.readUnsignedInt());
    int type = rawMessage.readUnsignedShort();
    ErrorTypeV10 errorType = ErrorTypeV10.forValue(type);
    decodeType(builder, errorType, type);
    decodeCode(rawMessage, builder, errorType);
    if (rawMessage.readableBytes() > 0) {
        builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array());
    }
    return builder.build();
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FeaturesReplyMessageFactory.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 av  a  2 s  .  c  om*/
    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());
    rawMessage.skipBytes(PADDING_IN_FEATURES_REPLY_HEADER);
    builder.setCapabilitiesV10(createCapabilitiesV10(rawMessage.readUnsignedInt()));
    builder.setActionsV10(createActionsV10(rawMessage.readUnsignedInt()));
    List<PhyPort> ports = new ArrayList<>();
    while (rawMessage.readableBytes() > 0) {
        ports.add(deserializePort(rawMessage));
    }
    builder.setPhyPort(ports);
    return builder.build();
}

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

License:Open Source License

private static PhyPort deserializePort(ByteBuf rawMessage) {
    PhyPortBuilder builder = new PhyPortBuilder();
    builder.setPortNo((long) rawMessage.readUnsignedShort());
    byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
    rawMessage.readBytes(address);/*from  ww  w .  j  ava2s.  co  m*/
    builder.setHwAddr(new MacAddress(ByteBufUtils.macAddressToString(address)));
    builder.setName(ByteBufUtils.decodeNullTerminatedString(rawMessage, EncodeConstants.MAX_PORT_NAME_LENGTH));
    builder.setConfigV10(createPortConfig(rawMessage.readUnsignedInt()));
    builder.setStateV10(createPortState(rawMessage.readUnsignedInt()));
    builder.setCurrentFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt()));
    builder.setAdvertisedFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt()));
    builder.setSupportedFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt()));
    builder.setPeerFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt()));
    return builder.build();
}