Example usage for io.netty.buffer ByteBuf readUnsignedShort

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

Introduction

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

Prototype

public abstract int readUnsignedShort();

Source Link

Document

Gets an unsigned 16-bit short integer at the current readerIndex and increases the readerIndex by 2 in this buffer.

Usage

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetVlanVidActionDeserializer.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();
    input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    SetVlanVidCaseBuilder caseBuilder = new SetVlanVidCaseBuilder();
    SetVlanVidActionBuilder actionBuilder = new SetVlanVidActionBuilder();
    actionBuilder.setVlanVid(input.readUnsignedShort());
    caseBuilder.setSetVlanVidAction(actionBuilder.build());
    builder.setActionChoice(caseBuilder.build());
    input.skipBytes(ActionConstants.PADDING_IN_SET_VLAN_VID_ACTION);
    return builder.build();
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13OutputActionDeserializer.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();
    input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
    OutputActionBuilder actionBuilder = new OutputActionBuilder();
    actionBuilder.setPort(new PortNumber(input.readUnsignedInt()));
    actionBuilder.setMaxLength(input.readUnsignedShort());
    caseBuilder.setOutputAction(actionBuilder.build());
    builder.setActionChoice(caseBuilder.build());
    input.skipBytes(ActionConstants.OUTPUT_PADDING);
    return builder.build();
}

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.experimenter.BundleControlFactory.java

License:Open Source License

@Override
public BundleControl deserialize(ByteBuf message) {
    BundleId bundleId = new BundleId(message.readUnsignedInt());
    BundleControlType type = BundleControlType.forValue(message.readUnsignedShort());
    BundleFlags flags = createBundleFlags(message.readUnsignedShort());
    BundleControlBuilder builder = new BundleControlBuilder();
    List<BundleProperty> properties = createBundleProperties(message);
    return builder.setBundleId(bundleId).setType(type).setFlags(flags).setBundleProperty(properties).build();
}

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 {/*  ww w . j  av a 2 s. co m*/
            message.skipBytes(length);
        }
    }
    return properties;
}

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

License:Open Source License

@Override
public ErrorMessage deserialize(ByteBuf message) {
    ErrorMessageBuilder builder = new ErrorMessageBuilder();
    builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
    builder.setXid(message.readUnsignedInt());

    int type = message.readUnsignedShort();
    ErrorType errorType = ErrorType.forValue(type);
    if (errorType != null && errorType.equals(ErrorType.EXPERIMENTER)) {
        builder.setType(errorType.getIntValue());
        builder.setTypeString(errorType.getName());
    } else {/*from w  w w .  j ava 2 s  .  c o m*/
        LOG.warn("Deserializing other than {} error message with {}", ErrorType.EXPERIMENTER.getName(),
                this.getClass().getCanonicalName());
        builder.setType(type);
        builder.setTypeString(UNKNOWN_TYPE);
    }

    int code = message.readUnsignedShort();
    OnfExperimenterErrorCode errorCode = OnfExperimenterErrorCode.forValue(code);
    if (errorCode != null) {
        builder.setCode(errorCode.getIntValue());
        builder.setCodeString(errorCode.getName());
    } else {
        builder.setCode(code);
        builder.setCodeString(UNKNOWN_CODE);
    }

    builder.addAugmentation(ExperimenterIdError.class, new ExperimenterIdErrorBuilder()
            .setExperimenter(new ExperimenterId(message.readUnsignedInt())).build());

    if (message.readableBytes() > 0) {
        byte[] data = new byte[message.readableBytes()];
        message.readBytes(data);
        builder.setData(data);
    }
    return builder.build();
}

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

License:Open Source License

@Override
public Action deserialize(ByteBuf input) {
    ActionBuilder builder = new ActionBuilder();
    input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    builder.setType(Experimenter.class);
    int length = input.readUnsignedShort();
    // subtract experimenter header length
    length -= EncodeConstants.EXPERIMENTER_IDS_LENGTH;
    ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder();
    expBuilder.setExperimenter(input.readUnsignedInt());
    if (length > 0) {
        byte[] data = new byte[length];
        input.readBytes(data);//from  w w  w. j  a v a  2s. c  om
        expBuilder.setData(data);
    }
    builder.addAugmentation(ExperimenterAction.class, expBuilder.build());
    return builder.build();
}