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

License:Open Source License

private static List<TableFeatureProperties> createTableFeaturesProperties(ByteBuf input, int length) {
    List<TableFeatureProperties> properties = new ArrayList<>();
    int tableFeaturesLength = length;
    while (tableFeaturesLength > 0) {
        TableFeaturePropertiesBuilder builder = new TableFeaturePropertiesBuilder();
        TableFeaturesPropType type = TableFeaturesPropType.forValue(input.readUnsignedShort());
        builder.setType(type);/*  w w  w . j  a  v  a 2 s.com*/
        int propertyLength = input.readUnsignedShort();
        int paddingRemainder = propertyLength % EncodeConstants.PADDING;
        tableFeaturesLength -= propertyLength;
        if (type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONS)
                || type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS)) {
            InstructionRelatedTableFeaturePropertyBuilder insBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
            insBuilder.setInstruction(InstructionsDeserializer.createInstructionIds(input,
                    propertyLength - COMMON_PROPERTY_LENGTH));
            builder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insBuilder.build());
        } else if (type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLES)
                || type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS)) {
            propertyLength -= COMMON_PROPERTY_LENGTH;
            NextTableRelatedTableFeaturePropertyBuilder tableBuilder = new NextTableRelatedTableFeaturePropertyBuilder();
            List<NextTableIds> ids = new ArrayList<>();
            while (propertyLength > 0) {
                NextTableIdsBuilder nextTableIdsBuilder = new NextTableIdsBuilder();
                nextTableIdsBuilder.setTableId(input.readUnsignedByte());
                ids.add(nextTableIdsBuilder.build());
                propertyLength--;
            }
            tableBuilder.setNextTableIds(ids);
            builder.addAugmentation(NextTableRelatedTableFeatureProperty.class, tableBuilder.build());
        } else if (type.equals(TableFeaturesPropType.OFPTFPTWRITEACTIONS)
                || type.equals(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS)
                || type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONS)
                || type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS)) {
            ActionRelatedTableFeaturePropertyBuilder actionBuilder = new ActionRelatedTableFeaturePropertyBuilder();
            actionBuilder.setAction(
                    ActionsDeserializer.createActionIds(input, propertyLength - COMMON_PROPERTY_LENGTH));
            builder.addAugmentation(ActionRelatedTableFeatureProperty.class, actionBuilder.build());
        } else if (type.equals(TableFeaturesPropType.OFPTFPTMATCH)
                || type.equals(TableFeaturesPropType.OFPTFPTWILDCARDS)
                || type.equals(TableFeaturesPropType.OFPTFPTWRITESETFIELD)
                || type.equals(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS)
                || type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD)
                || type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS)) {
            OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
            oxmBuilder.setMatchEntries(
                    MatchDeserializer.createMatchIds(input, propertyLength - COMMON_PROPERTY_LENGTH));
            builder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
        } else if (type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTER)
                || type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS)) {
            ExperimenterRelatedTableFeaturePropertyBuilder expBuilder = new ExperimenterRelatedTableFeaturePropertyBuilder();
            expBuilder.setExperimenter(input.readUnsignedInt());
            expBuilder.setExpType(input.readUnsignedInt());
            int dataLength = propertyLength - COMMON_PROPERTY_LENGTH - 2 * EncodeConstants.SIZE_OF_INT_IN_BYTES;
            if (dataLength > 0) {
                byte[] data = new byte[dataLength];
                input.readBytes(data);
                expBuilder.setData(data);
            }
            builder.addAugmentation(ExperimenterRelatedTableFeatureProperty.class, expBuilder.build());
        }
        if (paddingRemainder != 0) {
            input.skipBytes(EncodeConstants.PADDING - paddingRemainder);
            tableFeaturesLength -= EncodeConstants.PADDING - paddingRemainder;
        }
        properties.add(builder.build());
    }
    return properties;
}

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

License:Open Source License

private static MultipartReplyPortStatsCase setPortStats(ByteBuf input) {
    MultipartReplyPortStatsCaseBuilder caseBuilder = new MultipartReplyPortStatsCaseBuilder();
    MultipartReplyPortStatsBuilder builder = new MultipartReplyPortStatsBuilder();
    List<PortStats> portStatsList = new ArrayList<>();
    while (input.readableBytes() > 0) {
        PortStatsBuilder portStatsBuilder = new PortStatsBuilder();
        portStatsBuilder.setPortNo(input.readUnsignedInt());
        input.skipBytes(PADDING_IN_PORT_STATS_HEADER);
        byte[] rxPackets = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(rxPackets);/*from w  ww.  ja v  a  2s.c  o m*/
        portStatsBuilder.setRxPackets(new BigInteger(1, rxPackets));
        byte[] txPackets = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(txPackets);
        portStatsBuilder.setTxPackets(new BigInteger(1, txPackets));
        byte[] rxBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(rxBytes);
        portStatsBuilder.setRxBytes(new BigInteger(1, rxBytes));
        byte[] txBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(txBytes);
        portStatsBuilder.setTxBytes(new BigInteger(1, txBytes));
        byte[] rxDropped = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(rxDropped);
        portStatsBuilder.setRxDropped(new BigInteger(1, rxDropped));
        byte[] txDropped = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(txDropped);
        portStatsBuilder.setTxDropped(new BigInteger(1, txDropped));
        byte[] rxErrors = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(rxErrors);
        portStatsBuilder.setRxErrors(new BigInteger(1, rxErrors));
        byte[] txErrors = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(txErrors);
        portStatsBuilder.setTxErrors(new BigInteger(1, txErrors));
        byte[] rxFrameErr = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(rxFrameErr);
        portStatsBuilder.setRxFrameErr(new BigInteger(1, rxFrameErr));
        byte[] rxOverErr = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(rxOverErr);
        portStatsBuilder.setRxOverErr(new BigInteger(1, rxOverErr));
        byte[] rxCrcErr = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(rxCrcErr);
        portStatsBuilder.setRxCrcErr(new BigInteger(1, rxCrcErr));
        byte[] collisions = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(collisions);
        portStatsBuilder.setCollisions(new BigInteger(1, collisions));
        portStatsBuilder.setDurationSec(input.readUnsignedInt());
        portStatsBuilder.setDurationNsec(input.readUnsignedInt());
        portStatsList.add(portStatsBuilder.build());
    }
    builder.setPortStats(portStatsList);
    caseBuilder.setMultipartReplyPortStats(builder.build());
    return caseBuilder.build();
}

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

License:Open Source License

private static MultipartReplyGroupCase setGroup(ByteBuf input) {
    MultipartReplyGroupCaseBuilder caseBuilder = new MultipartReplyGroupCaseBuilder();
    MultipartReplyGroupBuilder builder = new MultipartReplyGroupBuilder();
    List<GroupStats> groupStatsList = new ArrayList<>();
    while (input.readableBytes() > 0) {
        GroupStatsBuilder groupStatsBuilder = new GroupStatsBuilder();
        int bodyLength = input.readUnsignedShort();
        input.skipBytes(PADDING_IN_GROUP_HEADER_01);
        groupStatsBuilder.setGroupId(new GroupId(input.readUnsignedInt()));
        groupStatsBuilder.setRefCount(input.readUnsignedInt());
        input.skipBytes(PADDING_IN_GROUP_HEADER_02);
        byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(packetCount);//from ww w.ja  v  a  2 s .  co  m
        groupStatsBuilder.setPacketCount(new BigInteger(1, packetCount));
        byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(byteCount);
        groupStatsBuilder.setByteCount(new BigInteger(1, byteCount));
        groupStatsBuilder.setDurationSec(input.readUnsignedInt());
        groupStatsBuilder.setDurationNsec(input.readUnsignedInt());
        int actualLength = GROUP_BODY_LENGTH;
        List<BucketStats> bucketStatsList = new ArrayList<>();
        while (actualLength < bodyLength) {
            BucketStatsBuilder bucketStatsBuilder = new BucketStatsBuilder();
            byte[] packetCountBucket = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
            input.readBytes(packetCountBucket);
            bucketStatsBuilder.setPacketCount(new BigInteger(1, packetCountBucket));
            byte[] byteCountBucket = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
            input.readBytes(byteCountBucket);
            bucketStatsBuilder.setByteCount(new BigInteger(1, byteCountBucket));
            bucketStatsList.add(bucketStatsBuilder.build());
            actualLength += BUCKET_COUNTER_LENGTH;
        }
        groupStatsBuilder.setBucketStats(bucketStatsList);
        groupStatsList.add(groupStatsBuilder.build());
    }
    builder.setGroupStats(groupStatsList);
    caseBuilder.setMultipartReplyGroup(builder.build());
    return caseBuilder.build();
}

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

License:Open Source License

private static MultipartReplyMeterFeaturesCase setMeterFeatures(ByteBuf input) {
    MultipartReplyMeterFeaturesCaseBuilder caseBuilder = new MultipartReplyMeterFeaturesCaseBuilder();
    MultipartReplyMeterFeaturesBuilder builder = new MultipartReplyMeterFeaturesBuilder();
    builder.setMaxMeter(input.readUnsignedInt());
    builder.setBandTypes(createMeterBandsBitmap(input.readUnsignedInt()));
    builder.setCapabilities(createMeterFlags(input.readUnsignedInt()));
    builder.setMaxBands(input.readUnsignedByte());
    builder.setMaxColor(input.readUnsignedByte());
    input.skipBytes(PADDING_IN_METER_FEATURES_HEADER);
    caseBuilder.setMultipartReplyMeterFeatures(builder.build());
    return caseBuilder.build();
}

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

License:Open Source License

private static MultipartReplyMeterCase setMeter(ByteBuf input) {
    MultipartReplyMeterCaseBuilder caseBuilder = new MultipartReplyMeterCaseBuilder();
    MultipartReplyMeterBuilder builder = new MultipartReplyMeterBuilder();
    List<MeterStats> meterStatsList = new ArrayList<>();
    while (input.readableBytes() > 0) {
        MeterStatsBuilder meterStatsBuilder = new MeterStatsBuilder();
        meterStatsBuilder.setMeterId(new MeterId(input.readUnsignedInt()));
        int meterStatsBodyLength = input.readUnsignedShort();
        input.skipBytes(PADDING_IN_METER_STATS_HEADER);
        meterStatsBuilder.setFlowCount(input.readUnsignedInt());
        byte[] packetInCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(packetInCount);/*from   ww  w  . java  2 s. c o  m*/
        meterStatsBuilder.setPacketInCount(new BigInteger(1, packetInCount));
        byte[] byteInCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(byteInCount);
        meterStatsBuilder.setByteInCount(new BigInteger(1, byteInCount));
        meterStatsBuilder.setDurationSec(input.readUnsignedInt());
        meterStatsBuilder.setDurationNsec(input.readUnsignedInt());
        int actualLength = METER_BODY_LENGTH;
        List<MeterBandStats> meterBandStatsList = new ArrayList<>();
        while (actualLength < meterStatsBodyLength) {
            MeterBandStatsBuilder meterBandStatsBuilder = new MeterBandStatsBuilder();
            byte[] packetBandCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
            input.readBytes(packetBandCount);
            meterBandStatsBuilder.setPacketBandCount(new BigInteger(1, packetBandCount));
            byte[] byteBandCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
            input.readBytes(byteBandCount);
            meterBandStatsBuilder.setByteBandCount(new BigInteger(1, byteBandCount));
            meterBandStatsList.add(meterBandStatsBuilder.build());
            actualLength += METER_BAND_STATS_LENGTH;
        }
        meterStatsBuilder.setMeterBandStats(meterBandStatsList);
        meterStatsList.add(meterStatsBuilder.build());
    }
    builder.setMeterStats(meterStatsList);
    caseBuilder.setMultipartReplyMeter(builder.build());
    return caseBuilder.build();
}

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

License:Open Source License

private static MultipartReplyMeterConfigCase setMeterConfig(ByteBuf input) {
    MultipartReplyMeterConfigCaseBuilder caseBuilder = new MultipartReplyMeterConfigCaseBuilder();
    MultipartReplyMeterConfigBuilder builder = new MultipartReplyMeterConfigBuilder();
    List<MeterConfig> meterConfigList = new ArrayList<>();
    while (input.readableBytes() > 0) {
        MeterConfigBuilder meterConfigBuilder = new MeterConfigBuilder();
        int meterConfigBodyLength = input.readUnsignedShort();
        meterConfigBuilder.setFlags(createMeterFlags(input.readUnsignedShort()));
        meterConfigBuilder.setMeterId(new MeterId(input.readUnsignedInt()));
        int actualLength = METER_CONFIG_LENGTH;
        List<Bands> bandsList = new ArrayList<>();
        while (actualLength < meterConfigBodyLength) {
            BandsBuilder bandsBuilder = new BandsBuilder();
            int bandType = input.readUnsignedShort();
            switch (bandType) {
            case 1:
                MeterBandDropCaseBuilder bandDropCaseBuilder = new MeterBandDropCaseBuilder();
                MeterBandDropBuilder bandDropBuilder = new MeterBandDropBuilder();
                bandDropBuilder.setType(MeterBandType.forValue(bandType));
                actualLength += input.readUnsignedShort();
                bandDropBuilder.setRate(input.readUnsignedInt());
                bandDropBuilder.setBurstSize(input.readUnsignedInt());
                input.skipBytes(PADDING_IN_METER_BAND_DROP_HEADER);
                bandDropCaseBuilder.setMeterBandDrop(bandDropBuilder.build());
                bandsBuilder.setMeterBand(bandDropCaseBuilder.build());
                break;
            case 2:
                MeterBandDscpRemarkCaseBuilder bandDscpRemarkCaseBuilder = new MeterBandDscpRemarkCaseBuilder();
                MeterBandDscpRemarkBuilder bandDscpRemarkBuilder = new MeterBandDscpRemarkBuilder();
                bandDscpRemarkBuilder.setType(MeterBandType.forValue(bandType));
                actualLength += input.readUnsignedShort();
                bandDscpRemarkBuilder.setRate(input.readUnsignedInt());
                bandDscpRemarkBuilder.setBurstSize(input.readUnsignedInt());
                bandDscpRemarkBuilder.setPrecLevel(input.readUnsignedByte());
                input.skipBytes(PADDING_IN_METER_BAND_DSCP_HEADER);
                bandDscpRemarkCaseBuilder.setMeterBandDscpRemark(bandDscpRemarkBuilder.build());
                bandsBuilder.setMeterBand(bandDscpRemarkCaseBuilder.build());
                break;
            case 0xFFFF:
                MeterBandExperimenterCaseBuilder bandExperimenterCaseBuilder = new MeterBandExperimenterCaseBuilder();
                MeterBandExperimenterBuilder bandExperimenterBuilder = new MeterBandExperimenterBuilder();
                bandExperimenterBuilder.setType(MeterBandType.forValue(bandType));
                actualLength += input.readUnsignedShort();
                bandExperimenterBuilder.setRate(input.readUnsignedInt());
                bandExperimenterBuilder.setBurstSize(input.readUnsignedInt());
                bandExperimenterBuilder.setExperimenter(input.readUnsignedInt());
                bandExperimenterCaseBuilder.setMeterBandExperimenter(bandExperimenterBuilder.build());
                bandsBuilder.setMeterBand(bandExperimenterCaseBuilder.build());
                break;
            default:
                break;
            }// www . j  av a  2 s  . c  om
            bandsList.add(bandsBuilder.build());
        }
        meterConfigBuilder.setBands(bandsList);
        meterConfigList.add(meterConfigBuilder.build());
    }
    builder.setMeterConfig(meterConfigList);
    caseBuilder.setMultipartReplyMeterConfig(builder.build());
    return caseBuilder.build();
}

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

License:Open Source License

private static MultipartReplyPortDescCase setPortDesc(ByteBuf input) {
    MultipartReplyPortDescCaseBuilder caseBuilder = new MultipartReplyPortDescCaseBuilder();
    MultipartReplyPortDescBuilder builder = new MultipartReplyPortDescBuilder();
    List<Ports> portsList = new ArrayList<>();
    while (input.readableBytes() > 0) {
        PortsBuilder portsBuilder = new PortsBuilder();
        portsBuilder.setPortNo(input.readUnsignedInt());
        input.skipBytes(PADDING_IN_PORT_DESC_HEADER_01);
        byte[] hwAddress = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
        input.readBytes(hwAddress);//from w ww  .  j  a va 2  s .  c  om
        portsBuilder.setHwAddr(new MacAddress(ByteBufUtils.macAddressToString(hwAddress)));
        input.skipBytes(PADDING_IN_PORT_DESC_HEADER_02);
        portsBuilder
                .setName(ByteBufUtils.decodeNullTerminatedString(input, EncodeConstants.MAX_PORT_NAME_LENGTH));
        portsBuilder.setConfig(createPortConfig(input.readUnsignedInt()));
        portsBuilder.setState(createPortState(input.readUnsignedInt()));
        portsBuilder.setCurrentFeatures(createPortFeatures(input.readUnsignedInt()));
        portsBuilder.setAdvertisedFeatures(createPortFeatures(input.readUnsignedInt()));
        portsBuilder.setSupportedFeatures(createPortFeatures(input.readUnsignedInt()));
        portsBuilder.setPeerFeatures(createPortFeatures(input.readUnsignedInt()));
        portsBuilder.setCurrSpeed(input.readUnsignedInt());
        portsBuilder.setMaxSpeed(input.readUnsignedInt());
        portsList.add(portsBuilder.build());
    }
    builder.setPorts(portsList);
    caseBuilder.setMultipartReplyPortDesc(builder.build());
    return caseBuilder.build();
}

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

License:Open Source License

private static MultipartReplyGroupDescCase setGroupDesc(ByteBuf input) {
    MultipartReplyGroupDescCaseBuilder caseBuilder = new MultipartReplyGroupDescCaseBuilder();
    MultipartReplyGroupDescBuilder builder = new MultipartReplyGroupDescBuilder();
    List<GroupDesc> groupDescsList = new ArrayList<>();
    while (input.readableBytes() > 0) {
        GroupDescBuilder groupDescBuilder = new GroupDescBuilder();
        int bodyLength = input.readUnsignedShort();
        groupDescBuilder.setType(GroupType.forValue(input.readUnsignedByte()));
        input.skipBytes(PADDING_IN_GROUP_DESC_HEADER);
        groupDescBuilder.setGroupId(new GroupId(input.readUnsignedInt()));
        int actualLength = GROUP_DESC_HEADER_LENGTH;
        List<BucketsList> bucketsList = new ArrayList<>();
        while (actualLength < bodyLength) {
            BucketsListBuilder bucketsBuilder = new BucketsListBuilder();
            int bucketsLength = input.readUnsignedShort();
            bucketsBuilder.setWeight(input.readUnsignedShort());
            bucketsBuilder.setWatchPort(new PortNumber(input.readUnsignedInt()));
            bucketsBuilder.setWatchGroup(input.readUnsignedInt());
            input.skipBytes(PADDING_IN_BUCKETS_HEADER);
            List<Action> actionsList = ActionsDeserializer.createActions(input,
                    bucketsLength - BUCKETS_HEADER_LENGTH);
            bucketsBuilder.setAction(actionsList);
            bucketsList.add(bucketsBuilder.build());
            actualLength += bucketsLength;
        }//  w  w w  .  j ava  2 s .  c  o m
        groupDescBuilder.setBucketsList(bucketsList);
        groupDescsList.add(groupDescBuilder.build());
    }
    builder.setGroupDesc(groupDescsList);
    caseBuilder.setMultipartReplyGroupDesc(builder.build());
    return caseBuilder.build();
}

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

License:Open Source License

@Override
public GetFeaturesOutput bufferToMessage(ByteBuf rawMessage, short version) {
    GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder();
    builder.setVersion(version);/* w ww  . ja v  a 2 s  .  com*/
    builder.setXid(rawMessage.readUnsignedInt());
    byte[] datapathId = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    rawMessage.readBytes(datapathId);
    builder.setDatapathId(new BigInteger(1, datapathId));
    builder.setBuffers(rawMessage.readUnsignedInt());
    builder.setTables(rawMessage.readUnsignedByte());
    rawMessage.skipBytes(PADDING_IN_FEATURES_REPLY_HEADER);
    builder.setCapabilitiesV10(createCapabilitiesV10(rawMessage.readUnsignedInt()));
    builder.setActionsV10(createActionsV10(rawMessage.readUnsignedInt()));
    List<PhyPort> ports = new ArrayList<>();
    while (rawMessage.readableBytes() > 0) {
        ports.add(deserializePort(rawMessage));
    }
    builder.setPhyPort(ports);
    return builder.build();
}

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);//from w w  w .j  ava  2  s .c o  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();
}