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.factories.PacketInMessageFactory.java

License:Open Source License

@Override
public PacketInMessage bufferToMessage(ByteBuf rawMessage, short version) {
    PacketInMessageBuilder builder = new PacketInMessageBuilder();
    builder.setVersion(version);// w  w w.  j  a v  a  2  s  .  c o m
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setBufferId(rawMessage.readUnsignedInt());
    builder.setTotalLen(rawMessage.readUnsignedShort());
    builder.setReason(PacketInReason.forValue(rawMessage.readUnsignedByte()));
    builder.setTableId(new TableId((long) rawMessage.readUnsignedByte()));
    byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    rawMessage.readBytes(cookie);
    builder.setCookie(new BigInteger(1, cookie));
    builder.setMatch(MatchDeserializer.createMatch(rawMessage));
    rawMessage.skipBytes(PADDING_IN_PACKET_IN_HEADER);
    builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array());
    return builder.build();
}

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

License:Open Source License

@Override
public PacketOutInput deserialize(ByteBuf rawMessage) {
    PacketOutInputBuilder builder = new PacketOutInputBuilder();
    builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setBufferId(rawMessage.readUnsignedInt());
    builder.setInPort(new PortNumber(rawMessage.readUnsignedInt()));
    int actions_len = rawMessage.readShort();
    rawMessage.skipBytes(PADDING);
    CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
    List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, actions_len,
            rawMessage, keyMaker, registry);
    builder.setAction(actions);//from  w  w w  .  ja  va 2  s .c o 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.PortModInputMessageFactory.java

License:Open Source License

@Override
public PortModInput deserialize(final ByteBuf rawMessage) {
    PortModInputBuilder builder = new PortModInputBuilder();
    builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setPortNo(new PortNumber(rawMessage.readUnsignedInt()));
    rawMessage.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_1);
    builder.setHwAddress(ByteBufUtils.readIetfMacAddress(rawMessage));
    rawMessage.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_2);
    builder.setConfig(createPortConfig(rawMessage.readUnsignedInt()));
    builder.setMask(createPortConfig(rawMessage.readUnsignedInt()));
    builder.setAdvertise(createPortFeatures(rawMessage.readUnsignedInt()));
    rawMessage.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_3);
    return builder.build();
}

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

License:Open Source License

@Override
public PortStatusMessage bufferToMessage(ByteBuf rawMessage, short version) {
    PortStatusMessageBuilder builder = new PortStatusMessageBuilder();
    builder.setVersion(version);//from w w w.j  ava2 s .  c om
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setReason(PortReason.forValue(rawMessage.readUnsignedByte()));
    rawMessage.skipBytes(PADDING_IN_PORT_STATUS_HEADER);
    builder.setPortNo(rawMessage.readUnsignedInt());
    rawMessage.skipBytes(PADDING_IN_OFP_PORT_HEADER_1);
    byte[] hwAddress = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
    rawMessage.readBytes(hwAddress);
    builder.setHwAddr(new MacAddress(ByteBufUtils.macAddressToString(hwAddress)));
    rawMessage.skipBytes(PADDING_IN_OFP_PORT_HEADER_2);
    builder.setName(ByteBufUtils.decodeNullTerminatedString(rawMessage, EncodeConstants.MAX_PORT_NAME_LENGTH));
    builder.setConfig(createPortConfig(rawMessage.readUnsignedInt()));
    builder.setState(createPortState(rawMessage.readUnsignedInt()));
    builder.setCurrentFeatures(createPortFeatures(rawMessage.readUnsignedInt()));
    builder.setAdvertisedFeatures(createPortFeatures(rawMessage.readUnsignedInt()));
    builder.setSupportedFeatures(createPortFeatures(rawMessage.readUnsignedInt()));
    builder.setPeerFeatures(createPortFeatures(rawMessage.readUnsignedInt()));
    builder.setCurrSpeed(rawMessage.readUnsignedInt());
    builder.setMaxSpeed(rawMessage.readUnsignedInt());
    return builder.build();
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.QueueGetConfigReplyMessageFactory.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 a2  s . c om
    builder.setXid((rawMessage.readUnsignedInt()));
    builder.setPort(new PortNumber(rawMessage.readUnsignedInt()));
    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.QueueGetConfigReplyMessageFactory.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()));
        queueBuilder.setPort(new PortNumber(input.readUnsignedInt()));
        int length = input.readUnsignedShort();
        input.skipBytes(PADDING_IN_PACKET_QUEUE_HEADER);
        queueBuilder.setQueueProperty(createPropertiesList(input, length - PACKET_QUEUE_LENGTH));
        queuesList.add(queueBuilder.build());
    }/* w  ww .  j ava 2 s  .  co  m*/
    return queuesList;
}

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

License:Open Source License

private static List<QueueProperty> createPropertiesList(ByteBuf input, int length) {
    int propertiesLength = length;
    List<QueueProperty> propertiesList = new ArrayList<>();
    while (propertiesLength > 0) {
        QueuePropertyBuilder propertiesBuilder = new QueuePropertyBuilder();
        QueueProperties property = QueueProperties.forValue(input.readUnsignedShort());
        propertiesBuilder.setProperty(property);
        int currentPropertyLength = input.readUnsignedShort();
        propertiesLength -= currentPropertyLength;
        input.skipBytes(PADDING_IN_QUEUE_PROPERTY_HEADER);
        if (property.equals(QueueProperties.OFPQTMINRATE) || property.equals(QueueProperties.OFPQTMAXRATE)) {
            RateQueuePropertyBuilder rateBuilder = new RateQueuePropertyBuilder();
            rateBuilder.setRate(input.readUnsignedShort());
            propertiesBuilder.addAugmentation(RateQueueProperty.class, rateBuilder.build());
            input.skipBytes(PADDING_IN_RATE_QUEUE_PROPERTY);
        } else if (property.equals(QueueProperties.OFPQTEXPERIMENTER)) {
            ExperimenterQueuePropertyBuilder expBuilder = new ExperimenterQueuePropertyBuilder();
            expBuilder.setExperimenter(input.readUnsignedInt());
            input.skipBytes(PADDING_IN_EXPERIMENTER_QUEUE_PROPERTY);
            expBuilder.setData(input.readBytes(currentPropertyLength - EncodeConstants.SIZE_OF_INT_IN_BYTES
                    - PADDING_IN_EXPERIMENTER_QUEUE_PROPERTY).array());
            propertiesBuilder.addAugmentation(RateQueueProperty.class, expBuilder.build());
        }/*from w  w  w .  j a va2s  .  com*/
        propertiesList.add(propertiesBuilder.build());
    }
    return propertiesList;
}

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

License:Open Source License

@Override
public RoleRequestOutput bufferToMessage(ByteBuf rawMessage, short version) {
    RoleRequestOutputBuilder builder = new RoleRequestOutputBuilder();
    builder.setVersion(version);/*from ww  w .  java2s.c o  m*/
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setRole(ControllerRole.forValue((int) rawMessage.readUnsignedInt()));
    rawMessage.skipBytes(PADDING_IN_ROLE_REPLY_HEADER);
    byte[] generationID = new byte[8];
    rawMessage.readBytes(generationID);
    builder.setGenerationId(new BigInteger(1, generationID));
    return builder.build();
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.AbstractInstructionDeserializer.java

License:Open Source License

@Override
public Instruction deserializeHeader(ByteBuf rawMessage) {
    InstructionBuilder builder = processHeader(rawMessage);
    rawMessage.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    return builder.build();
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.ApplyActionsInstructionDeserializer.java

License:Open Source License

@Override
public Instruction deserialize(ByteBuf input) {
    InstructionBuilder builder = new InstructionBuilder();
    input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    int instructionLength = input.readUnsignedShort();
    input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
    ApplyActionsCaseBuilder caseBuilder = new ApplyActionsCaseBuilder();
    ApplyActionsBuilder actionsBuilder = new ApplyActionsBuilder();
    actionsBuilder.setAction(deserializeActions(input, instructionLength));
    caseBuilder.setApplyActions(actionsBuilder.build());
    builder.setInstructionChoice(caseBuilder.build());
    return builder.build();
}