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

License:Open Source License

@Override
public FlowRemovedMessage bufferToMessage(ByteBuf rawMessage, short version) {
    FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder();
    builder.setVersion(version);//  w  w  w.  java  2s .  co  m
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setMatchV10(OF10MatchDeserializer.createMatchV10(rawMessage));
    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()));
    rawMessage.skipBytes(PADDING_IN_FLOW_REMOVED_MESSAGE);
    builder.setDurationSec(rawMessage.readUnsignedInt());
    builder.setDurationNsec(rawMessage.readUnsignedInt());
    builder.setIdleTimeout(rawMessage.readUnsignedShort());
    rawMessage.skipBytes(PADDING_IN_FLOW_REMOVED_MESSAGE_2);
    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));
    return builder.build();
}

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

License:Open Source License

@Override
public GetConfigOutput deserialize(ByteBuf rawMessage) {
    GetConfigOutputBuilder builder = new GetConfigOutputBuilder();
    builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
    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.OF10HelloMessageFactory.java

License:Open Source License

@Override
public HelloMessage bufferToMessage(ByteBuf rawMessage, short version) {
    HelloMessageBuilder builder = new HelloMessageBuilder();
    builder.setVersion(version);/*from w w w .  j a v  a 2s.c om*/
    builder.setXid(rawMessage.readUnsignedInt());
    if (rawMessage.readableBytes() > 0) {
        rawMessage.skipBytes(rawMessage.readableBytes());
    }
    return builder.build();
}

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

License:Open Source License

@Override
public PacketInMessage bufferToMessage(ByteBuf rawMessage, short version) {
    PacketInMessageBuilder builder = new PacketInMessageBuilder();
    builder.setVersion(version);//from w w  w  .j  a  v a 2s .c  o  m
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setBufferId(rawMessage.readUnsignedInt());
    builder.setTotalLen(rawMessage.readUnsignedShort());
    builder.setInPort(rawMessage.readUnsignedShort());
    builder.setReason(PacketInReason.forValue(rawMessage.readUnsignedByte()));
    rawMessage.skipBytes(PADDING_IN_PACKET_IN_HEADER);
    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.OF10PacketOutInputMessageFactory.java

License:Open Source License

@Override
public PacketOutInput deserialize(ByteBuf rawMessage) {
    PacketOutInputBuilder builder = new PacketOutInputBuilder();
    builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setBufferId(rawMessage.readUnsignedInt());
    builder.setInPort(new PortNumber((long) rawMessage.readUnsignedShort()));
    int actions_len = rawMessage.readShort();
    CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF10_VERSION_ID);
    List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF10_VERSION_ID, actions_len,
            rawMessage, keyMaker, registry);
    builder.setAction(actions);/*from w  ww  . j  av a2 s. co  m*/

    byte[] data = new byte[rawMessage.readableBytes()];
    rawMessage.readBytes(data);

    if (data != null) {

        builder.setData(data);
    }
    return builder.build();
}

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

License:Open Source License

@Override
public PortModInput deserialize(final ByteBuf rawMessage) {
    PortModInputBuilder builder = new PortModInputBuilder();
    builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setPortNo(new PortNumber((long) rawMessage.readUnsignedShort()));
    builder.setHwAddress(ByteBufUtils.readIetfMacAddress(rawMessage));
    builder.setConfigV10(createPortConfig(rawMessage.readUnsignedInt()));
    builder.setMaskV10(createPortConfig(rawMessage.readUnsignedInt()));
    builder.setAdvertiseV10(createPortFeatures(rawMessage.readUnsignedInt()));
    return builder.build();
}

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

License:Open Source License

@Override
public PortStatusMessage bufferToMessage(ByteBuf rawMessage, short version) {
    PortStatusMessageBuilder builder = new PortStatusMessageBuilder();
    builder.setVersion(version);/*  w w w  . java 2 s.c om*/
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setReason(PortReason.forValue(rawMessage.readUnsignedByte()));
    rawMessage.skipBytes(PADDING_IN_PORT_STATUS_HEADER);
    deserializePort(rawMessage, builder);
    return builder.build();
}

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

License:Open Source License

private static void deserializePort(ByteBuf rawMessage, PortStatusMessageBuilder builder) {
    builder.setPortNo((long) rawMessage.readUnsignedShort());
    byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
    rawMessage.readBytes(address);/* w w  w.  jav  a  2s  .  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()));
}

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

License:Open Source License

@Override
public GetQueueConfigOutput bufferToMessage(ByteBuf rawMessage, short version) {
    GetQueueConfigOutputBuilder builder = new GetQueueConfigOutputBuilder();
    builder.setVersion(version);/*from  w w  w.ja v a 2  s.c  o  m*/
    builder.setXid((rawMessage.readUnsignedInt()));
    builder.setPort(new PortNumber((long) rawMessage.readUnsignedShort()));
    rawMessage.skipBytes(PADDING_IN_QUEUE_GET_CONFIG_REPLY_HEADER);
    builder.setQueues(createQueuesList(rawMessage));
    return builder.build();
}

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

License:Open Source License

private static List<Queues> createQueuesList(ByteBuf input) {
    List<Queues> queuesList = new ArrayList<>();
    while (input.readableBytes() > 0) {
        QueuesBuilder queueBuilder = new QueuesBuilder();
        queueBuilder.setQueueId(new QueueId(input.readUnsignedInt()));
        int length = input.readUnsignedShort();
        input.skipBytes(PADDING_IN_PACKET_QUEUE_HEADER);
        queueBuilder.setQueueProperty(createPropertiesList(input, length - PACKET_QUEUE_HEADER_LENGTH));
        queuesList.add(queueBuilder.build());
    }/*w  w  w  . ja  v  a2  s . c  om*/
    return queuesList;
}