List of usage examples for io.netty.buffer ByteBuf readUnsignedInt
public abstract long readUnsignedInt();
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory.java
License:Open Source License
private static MultipartReplyAggregateCase setAggregate(ByteBuf input) { MultipartReplyAggregateCaseBuilder caseBuilder = new MultipartReplyAggregateCaseBuilder(); MultipartReplyAggregateBuilder builder = new MultipartReplyAggregateBuilder(); byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(packetCount);// w w w . j a va 2s . c o m builder.setPacketCount(new BigInteger(1, packetCount)); byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(byteCount); builder.setByteCount(new BigInteger(1, byteCount)); builder.setFlowCount(input.readUnsignedInt()); input.skipBytes(PADDING_IN_AGGREGATE_HEADER); caseBuilder.setMultipartReplyAggregate(builder.build()); return caseBuilder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory.java
License:Open Source License
private static MultipartReplyTableCase setTable(ByteBuf input) { MultipartReplyTableCaseBuilder caseBuilder = new MultipartReplyTableCaseBuilder(); MultipartReplyTableBuilder builder = new MultipartReplyTableBuilder(); List<TableStats> tableStatsList = new ArrayList<>(); while (input.readableBytes() > 0) { TableStatsBuilder tableStatsBuilder = new TableStatsBuilder(); tableStatsBuilder.setTableId(input.readUnsignedByte()); input.skipBytes(PADDING_IN_TABLE_HEADER); tableStatsBuilder.setActiveCount(input.readUnsignedInt()); byte[] lookupCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(lookupCount);// w w w . j ava 2 s . c o m tableStatsBuilder.setLookupCount(new BigInteger(1, lookupCount)); byte[] matchedCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(matchedCount); tableStatsBuilder.setMatchedCount(new BigInteger(1, matchedCount)); tableStatsList.add(tableStatsBuilder.build()); } builder.setTableStats(tableStatsList); caseBuilder.setMultipartReplyTable(builder.build()); return caseBuilder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory.java
License:Open Source License
private static MultipartReplyTableFeaturesCase setTableFeatures(ByteBuf input) { MultipartReplyTableFeaturesCaseBuilder caseBuilder = new MultipartReplyTableFeaturesCaseBuilder(); MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder(); List<TableFeatures> features = new ArrayList<>(); while (input.readableBytes() > 0) { TableFeaturesBuilder featuresBuilder = new TableFeaturesBuilder(); int length = input.readUnsignedShort(); featuresBuilder.setTableId(input.readUnsignedByte()); input.skipBytes(PADDING_IN_MULTIPART_REPLY_TABLE_FEATURES); featuresBuilder.setName(input.readBytes(MAX_TABLE_NAME_LENGTH).toString()); byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(metadataMatch);//from w w w .ja v a2s . c om featuresBuilder.setMetadataMatch(metadataMatch); byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(metadataWrite); featuresBuilder.setMetadataWrite(metadataWrite); featuresBuilder.setConfig(createTableConfig(input.readUnsignedInt())); featuresBuilder.setMaxEntries(input.readUnsignedInt()); featuresBuilder.setTableFeatureProperties( createTableFeaturesProperties(input, length - MULTIPART_REPLY_TABLE_FEATURES_STRUCTURE_LENGTH)); features.add(featuresBuilder.build()); } builder.setTableFeatures(features); caseBuilder.setMultipartReplyTableFeatures(builder.build()); return caseBuilder.build(); }
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);//from w ww .j a v a 2 s .co m 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 ww w.jav a 2 s. c om 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 MultipartReplyQueueCase setQueue(ByteBuf input) { MultipartReplyQueueCaseBuilder caseBuilder = new MultipartReplyQueueCaseBuilder(); MultipartReplyQueueBuilder builder = new MultipartReplyQueueBuilder(); List<QueueStats> queueStatsList = new ArrayList<>(); while (input.readableBytes() > 0) { QueueStatsBuilder queueStatsBuilder = new QueueStatsBuilder(); queueStatsBuilder.setPortNo(input.readUnsignedInt()); queueStatsBuilder.setQueueId(input.readUnsignedInt()); byte[] txBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(txBytes);//from w w w. ja va2 s . c om queueStatsBuilder.setTxBytes(new BigInteger(1, txBytes)); byte[] txPackets = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(txPackets); queueStatsBuilder.setTxPackets(new BigInteger(1, txPackets)); byte[] txErrors = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(txErrors); queueStatsBuilder.setTxErrors(new BigInteger(1, txErrors)); queueStatsBuilder.setDurationSec(input.readUnsignedInt()); queueStatsBuilder.setDurationNsec(input.readUnsignedInt()); queueStatsList.add(queueStatsBuilder.build()); } builder.setQueueStats(queueStatsList); caseBuilder.setMultipartReplyQueue(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);/* www .j a v a2 s .c o 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 . ja v a 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; }/* ww w . ja v a 2s .c o m*/ bandsList.add(bandsBuilder.build()); } meterConfigBuilder.setBands(bandsList); meterConfigList.add(meterConfigBuilder.build()); } builder.setMeterConfig(meterConfigList); caseBuilder.setMultipartReplyMeterConfig(builder.build()); return caseBuilder.build(); }