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.action.OF13PopMplsActionDeserializer.java

License:Open Source License

@Override
public Action deserialize(ByteBuf input) {
    ActionBuilder builder = new ActionBuilder();
    input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    PopMplsCaseBuilder caseBuilder = new PopMplsCaseBuilder();
    PopMplsActionBuilder mplsBuilder = new PopMplsActionBuilder();
    mplsBuilder.setEthertype(new EtherType(input.readUnsignedShort()));
    caseBuilder.setPopMplsAction(mplsBuilder.build());
    builder.setActionChoice(caseBuilder.build());
    input.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING);
    return builder.build();
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PushMplsActionDeserializer.java

License:Open Source License

@Override
public Action deserialize(ByteBuf input) {
    ActionBuilder builder = new ActionBuilder();
    input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    PushMplsCaseBuilder caseBuilder = new PushMplsCaseBuilder();
    PushMplsActionBuilder mplsBuilder = new PushMplsActionBuilder();
    mplsBuilder.setEthertype(new EtherType(input.readUnsignedShort()));
    caseBuilder.setPushMplsAction(mplsBuilder.build());
    builder.setActionChoice(caseBuilder.build());
    input.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING);
    return builder.build();
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PushPbbActionDeserializer.java

License:Open Source License

@Override
public Action deserialize(ByteBuf input) {
    ActionBuilder builder = new ActionBuilder();
    input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    PushPbbCaseBuilder caseBuilder = new PushPbbCaseBuilder();
    PushPbbActionBuilder pbbBuilder = new PushPbbActionBuilder();
    pbbBuilder.setEthertype(new EtherType(input.readUnsignedShort()));
    caseBuilder.setPushPbbAction(pbbBuilder.build());
    builder.setActionChoice(caseBuilder.build());
    input.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING);
    return builder.build();
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PushVlanActionDeserializer.java

License:Open Source License

@Override
public Action deserialize(ByteBuf input) {
    ActionBuilder builder = new ActionBuilder();
    input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    PushVlanCaseBuilder caseBuilder = new PushVlanCaseBuilder();
    PushVlanActionBuilder vlanBuilder = new PushVlanActionBuilder();
    vlanBuilder.setEthertype(new EtherType(input.readUnsignedShort()));
    caseBuilder.setPushVlanAction(vlanBuilder.build());
    builder.setActionChoice(caseBuilder.build());
    input.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING);
    return builder.build();
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetFieldActionDeserializer.java

License:Open Source License

@Override
public Action deserialize(ByteBuf input) {
    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder builder = new ActionBuilder();
    int startIndex = input.readerIndex();
    input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    SetFieldCaseBuilder caseBuilder = new SetFieldCaseBuilder();
    SetFieldActionBuilder actionBuilder = new SetFieldActionBuilder();
    int oxmClass = input.getUnsignedShort(input.readerIndex());
    // get oxm_field & hasMask byte and extract the field value
    int oxmField = input.getUnsignedByte(input.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1;
    MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, oxmClass,
            oxmField);/*from w  w  w.ja va  2 s  .co m*/
    if (oxmClass == EncodeConstants.EXPERIMENTER_VALUE) {
        long expId = input.getUnsignedInt(input.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES
                + 2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
        key.setExperimenterId(expId);
    }
    OFDeserializer<MatchEntry> matchDeserializer = registry.getDeserializer(key);
    List<MatchEntry> entry = new ArrayList<>();
    entry.add(matchDeserializer.deserialize(input));
    actionBuilder.setMatchEntry(entry);
    caseBuilder.setSetFieldAction(actionBuilder.build());
    builder.setActionChoice(caseBuilder.build());
    int paddingRemainder = (input.readerIndex() - startIndex) % EncodeConstants.PADDING;
    if (paddingRemainder != 0) {
        input.skipBytes(EncodeConstants.PADDING - paddingRemainder);
    }
    return builder.build();
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetMplsTtlActionDeserializer.java

License:Open Source License

@Override
public Action deserialize(ByteBuf input) {
    ActionBuilder builder = new ActionBuilder();
    input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    SetMplsTtlCaseBuilder caseBuilder = new SetMplsTtlCaseBuilder();
    SetMplsTtlActionBuilder actionBuilder = new SetMplsTtlActionBuilder();
    actionBuilder.setMplsTtl(input.readUnsignedByte());
    caseBuilder.setSetMplsTtlAction(actionBuilder.build());
    builder.setActionChoice(caseBuilder.build());
    input.skipBytes(ActionConstants.SET_MPLS_TTL_PADDING);
    return builder.build();
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetNwTtlActionDeserializer.java

License:Open Source License

@Override
public Action deserialize(ByteBuf input) {
    ActionBuilder builder = new ActionBuilder();
    input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    SetNwTtlCaseBuilder caseBuilder = new SetNwTtlCaseBuilder();
    SetNwTtlActionBuilder actionBuilder = new SetNwTtlActionBuilder();
    actionBuilder.setNwTtl(input.readUnsignedByte());
    caseBuilder.setSetNwTtlAction(actionBuilder.build());
    builder.setActionChoice(caseBuilder.build());
    input.skipBytes(ActionConstants.SET_NW_TTL_PADDING);
    return builder.build();
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetQueueActionDeserializer.java

License:Open Source License

@Override
public Action deserialize(ByteBuf input) {
    ActionBuilder builder = new ActionBuilder();
    input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    SetQueueCaseBuilder caseBuilder = new SetQueueCaseBuilder();
    SetQueueActionBuilder actionBuilder = new SetQueueActionBuilder();
    actionBuilder.setQueueId(input.readUnsignedInt());
    caseBuilder.setSetQueueAction(actionBuilder.build());
    builder.setActionChoice(caseBuilder.build());
    return builder.build();
}

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

License:Open Source License

/**
 * Transforms ByteBuf into correct POJO message
 * @param rawMessage /* w ww . j  av a2 s.  c om*/
 * @param version version decoded from OpenFlow protocol message
 * @return correct POJO as DataObject
 */
public static DataObject bufferToMessage(ByteBuf rawMessage, short version) {
    DataObject dataObject = null;
    short type = rawMessage.readUnsignedByte();
    rawMessage.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);

    MessageTypeCodeKey msgTypeCodeKey = new MessageTypeCodeKey(version, type);
    OFDeserializer<?> decoder = DecoderTable.getInstance().getDecoder(msgTypeCodeKey);
    if (decoder != null) {
        dataObject = decoder.bufferToMessage(rawMessage, version);
    } else {
        LOGGER.warn("No correct decoder found in DecoderTable for arguments: " + msgTypeCodeKey.toString());
    }
    return dataObject;
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.experimenter.BundleControlFactory.java

License:Open Source License

private List<BundleProperty> createBundleProperties(final ByteBuf message) {
    List<BundleProperty> properties = new ArrayList<>();
    while (message.readableBytes() > 0) {
        BundlePropertyType type = BundlePropertyType.forValue(message.readUnsignedShort());
        int length = message.readUnsignedShort();
        if (type != null && type.equals(BundlePropertyType.ONFETBPTEXPERIMENTER)) {
            properties.add(createExperimenterBundleProperty(length, message));
        } else {//from w w w.j  av  a 2s . co m
            message.skipBytes(length);
        }
    }
    return properties;
}