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.nx.codec.action.LearnCodecUtil.java

License:Open Source License

private static FlowMods readFlowModCopyFromValue(ByteBuf message, short numBits) {
    FlowModCopyValueIntoFieldBuilder builder = new FlowModCopyValueIntoFieldBuilder();
    builder.setValue((int) message.readUnsignedShort());
    builder.setDstField((long) message.readInt());
    builder.setDstOfs((int) message.readShort());
    builder.setFlowModNumBits((int) numBits);
    length -= FROM_VALUE_LENGTH - EncodeConstants.SIZE_OF_SHORT_IN_BYTES;

    FlowModsBuilder flowModsBuilder = new FlowModsBuilder();
    FlowModCopyValueIntoFieldCaseBuilder caseBuilder = new FlowModCopyValueIntoFieldCaseBuilder();
    caseBuilder.setFlowModCopyValueIntoField(builder.build());
    flowModsBuilder.setFlowModSpec(caseBuilder.build());
    return flowModsBuilder.build();
}

From source file:org.opendaylight.openflowjava.nx.codec.action.MultipathCodec.java

License:Open Source License

@Override
public Action deserialize(final ByteBuf message) {
    ActionBuilder actionBuilder = deserializeHeader(message);
    ActionMultipathBuilder actionMultipathBuilder = new ActionMultipathBuilder();

    NxActionMultipathBuilder nxActionMultipathBuilder = new NxActionMultipathBuilder();
    nxActionMultipathBuilder.setFields(OfjNxHashFields.forValue(message.readUnsignedShort()));
    nxActionMultipathBuilder.setBasis(message.readUnsignedShort());
    message.skipBytes(2); //two bytes

    nxActionMultipathBuilder.setAlgorithm(OfjNxMpAlgorithm.forValue(message.readUnsignedShort()));
    nxActionMultipathBuilder.setMaxLink(message.readUnsignedShort());
    nxActionMultipathBuilder.setArg(message.readUnsignedInt());
    message.skipBytes(2); //two bytes

    nxActionMultipathBuilder.setOfsNbits(message.readUnsignedShort());
    nxActionMultipathBuilder.setDst(message.readUnsignedInt());
    actionMultipathBuilder.setNxActionMultipath(nxActionMultipathBuilder.build());
    actionBuilder.setActionChoice(actionMultipathBuilder.build());

    return actionBuilder.build();
}

From source file:org.opendaylight.openflowjava.nx.codec.action.OutputRegCodec.java

License:Open Source License

@Override
public Action deserialize(final ByteBuf message) {
    ActionBuilder actionBuilder = deserializeHeader(message);
    ActionOutputRegBuilder builder = new ActionOutputRegBuilder();
    NxActionOutputRegBuilder nxActionOutputRegBuilder = new NxActionOutputRegBuilder();
    nxActionOutputRegBuilder.setNBits(message.readUnsignedShort());
    nxActionOutputRegBuilder.setSrc(message.readUnsignedInt());
    nxActionOutputRegBuilder.setMaxLen(message.readUnsignedShort());
    message.skipBytes(PADDING_IN_OUTPUT_REG_ACTION);
    builder.setNxActionOutputReg(nxActionOutputRegBuilder.build());
    actionBuilder.setActionChoice(builder.build());
    return actionBuilder.build();
}

From source file:org.opendaylight.openflowjava.nx.codec.action.RegLoadCodec.java

License:Open Source License

@Override
public Action deserialize(final ByteBuf message) {
    ActionBuilder actionBuilder = deserializeHeader(message);
    NxActionRegLoadBuilder nxActionRegLoadBuilder = new NxActionRegLoadBuilder();
    ActionRegLoadBuilder actionRegLoadBuilder = new ActionRegLoadBuilder();
    nxActionRegLoadBuilder.setOfsNbits(message.readUnsignedShort());
    nxActionRegLoadBuilder.setDst(message.readUnsignedInt());
    nxActionRegLoadBuilder.setValue(BigInteger.valueOf(message.readLong()));
    actionRegLoadBuilder.setNxActionRegLoad(nxActionRegLoadBuilder.build());
    actionBuilder.setActionChoice(actionRegLoadBuilder.build());
    return actionBuilder.build();
}

From source file:org.opendaylight.openflowjava.nx.codec.action.RegMoveCodec.java

License:Open Source License

@Override
public Action deserialize(final ByteBuf message) {
    ActionBuilder actionBuilder = deserializeHeader(message);
    ActionRegMoveBuilder actionRegMoveBuilder = new ActionRegMoveBuilder();
    NxActionRegMoveBuilder nxActionRegMoveBuilder = new NxActionRegMoveBuilder();
    nxActionRegMoveBuilder.setNBits(message.readUnsignedShort());
    nxActionRegMoveBuilder.setSrcOfs(message.readUnsignedShort());
    nxActionRegMoveBuilder.setDstOfs(message.readUnsignedShort());
    nxActionRegMoveBuilder.setSrc(message.readUnsignedInt());
    nxActionRegMoveBuilder.setDst(message.readUnsignedInt());
    actionRegMoveBuilder.setNxActionRegMove(nxActionRegMoveBuilder.build());
    actionBuilder.setActionChoice(actionRegMoveBuilder.build());
    return actionBuilder.build();
}

From source file:org.opendaylight.openflowjava.nx.codec.action.ResubmitCodec.java

License:Open Source License

@Override
public Action deserialize(final ByteBuf message) {
    ActionBuilder actionBuilder = deserializeHeader(message);

    ActionResubmitBuilder builder = new ActionResubmitBuilder();
    NxActionResubmitBuilder nxActionResubmitBuilder = new NxActionResubmitBuilder();
    nxActionResubmitBuilder.setInPort(message.readUnsignedShort());
    nxActionResubmitBuilder.setTable(message.readUnsignedByte());
    builder.setNxActionResubmit(nxActionResubmitBuilder.build());
    message.skipBytes(padding);/* w w  w .ja va2  s.  c om*/

    actionBuilder.setActionChoice(builder.build());
    return actionBuilder.build();
}

From source file:org.opendaylight.openflowjava.nx.codec.match.ArpOpCodec.java

License:Open Source License

@Override
public MatchEntry deserialize(ByteBuf message) {
    MatchEntryBuilder matchEntryBuilder = deserializeHeader(message);
    ArpOpCaseValueBuilder caseBuilder = new ArpOpCaseValueBuilder();
    caseBuilder.setArpOpValues(new ArpOpValuesBuilder().setValue(message.readUnsignedShort()).build());
    matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
    return matchEntryBuilder.build();
}

From source file:org.opendaylight.openflowjava.nx.codec.match.CtZoneCodec.java

License:Open Source License

@Override
public MatchEntry deserialize(ByteBuf message) {
    MatchEntryBuilder matchEntryBuilder = deserializeHeader(message);
    CtZoneCaseValueBuilder caseBuilder = new CtZoneCaseValueBuilder();
    CtZoneValuesBuilder ctZoneValuesBuilder = new CtZoneValuesBuilder();
    ctZoneValuesBuilder.setCtZone(message.readUnsignedShort());
    caseBuilder.setCtZoneValues(ctZoneValuesBuilder.build());
    matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
    return matchEntryBuilder.build();
}

From source file:org.opendaylight.openflowjava.nx.codec.match.EncapEthTypeCodec.java

License:Open Source License

@Override
public MatchEntry deserialize(ByteBuf message) {
    MatchEntryBuilder matchEntryBuilder = deserializeHeader(message);
    EncapEthTypeCaseValueBuilder encapEthTypeCaseValueBuilder = new EncapEthTypeCaseValueBuilder();
    encapEthTypeCaseValueBuilder.setEncapEthTypeValues(
            new EncapEthTypeValuesBuilder().setEncapEthType(message.readUnsignedShort()).build());
    matchEntryBuilder.setMatchEntryValue(encapEthTypeCaseValueBuilder.build());
    matchEntryBuilder.setHasMask(false);
    return matchEntryBuilder.build();
}

From source file:org.opendaylight.openflowjava.nx.codec.match.EthTypeCodec.java

License:Open Source License

@Override
public MatchEntry deserialize(ByteBuf message) {
    MatchEntryBuilder matchEntryBuilder = deserializeHeader(message);
    EthTypeCaseValueBuilder caseBuilder = new EthTypeCaseValueBuilder();
    EthTypeValuesBuilder valuesBuilder = new EthTypeValuesBuilder();
    valuesBuilder.setValue(message.readUnsignedShort()).build();
    caseBuilder.setEthTypeValues(valuesBuilder.build());
    matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
    return matchEntryBuilder.build();
}