List of usage examples for io.netty.buffer ByteBuf readUnsignedInt
public abstract long readUnsignedInt();
From source file:org.opendaylight.netide.openflowjava.protocol.impl.deserialization.factories.MeterModInputMessageFactory.java
License:Open Source License
@Override public MeterModInput deserialize(ByteBuf rawMessage) { MeterModInputBuilder builder = new MeterModInputBuilder(); builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); builder.setXid(rawMessage.readUnsignedInt()); builder.setCommand(MeterModCommand.forValue(rawMessage.readUnsignedShort())); builder.setFlags(createMeterFlags(rawMessage.readUnsignedShort())); builder.setMeterId(new MeterId(rawMessage.readUnsignedInt())); List<Bands> bandsList = new ArrayList<>(); while (rawMessage.readableBytes() > 0) { BandsBuilder bandsBuilder = new BandsBuilder(); int bandStartIndex = rawMessage.readerIndex(); int bandType = rawMessage.readUnsignedShort(); switch (bandType) { case 1://from ww w .j a v a 2s .c om MeterBandDropCaseBuilder bandDropCaseBuilder = new MeterBandDropCaseBuilder(); MeterBandDropBuilder bandDropBuilder = new MeterBandDropBuilder(); bandDropBuilder.setType(MeterBandType.forValue(bandType)); rawMessage.readUnsignedShort(); bandDropBuilder.setRate(rawMessage.readUnsignedInt()); bandDropBuilder.setBurstSize(rawMessage.readUnsignedInt()); rawMessage.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)); rawMessage.readUnsignedShort(); bandDscpRemarkBuilder.setRate(rawMessage.readUnsignedInt()); bandDscpRemarkBuilder.setBurstSize(rawMessage.readUnsignedInt()); bandDscpRemarkBuilder.setPrecLevel(rawMessage.readUnsignedByte()); rawMessage.skipBytes(PADDING_IN_METER_BAND_DSCP_HEADER); bandDscpRemarkCaseBuilder.setMeterBandDscpRemark(bandDscpRemarkBuilder.build()); bandsBuilder.setMeterBand(bandDscpRemarkCaseBuilder.build()); break; case 0xFFFF: long expId = rawMessage .getUnsignedInt(rawMessage.readerIndex() + 2 * EncodeConstants.SIZE_OF_INT_IN_BYTES); rawMessage.readerIndex(bandStartIndex); OFDeserializer<MeterBandExperimenterCase> deserializer = registry .getDeserializer(ExperimenterDeserializerKeyFactory .createMeterBandDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId)); bandsBuilder.setMeterBand(deserializer.deserialize(rawMessage)); break; } bandsList.add(bandsBuilder.build()); } builder.setBands(bandsList); return builder.build(); }
From source file:org.opendaylight.netide.openflowjava.protocol.impl.deserialization.factories.MultipartRequestInputMessageFactory.java
License:Open Source License
@Override public MultipartRequestInput deserialize(ByteBuf rawMessage) { MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); builder.setXid(rawMessage.readUnsignedInt()); int type = rawMessage.readUnsignedShort(); builder.setType(getMultipartType(type)); builder.setFlags(getMultipartRequestFlags(rawMessage.readUnsignedShort())); rawMessage.skipBytes(PADDING);/* www.j a v a 2 s . co m*/ switch (MultipartType.forValue(type)) { case OFPMPDESC: builder.setMultipartRequestBody(setDesc(rawMessage)); break; case OFPMPFLOW: builder.setMultipartRequestBody(setFlow(rawMessage)); break; case OFPMPAGGREGATE: builder.setMultipartRequestBody(setAggregate(rawMessage)); break; case OFPMPTABLE: builder.setMultipartRequestBody(setTable(rawMessage)); break; case OFPMPTABLEFEATURES: builder.setMultipartRequestBody(setTableFeatures(rawMessage)); break; case OFPMPPORTSTATS: builder.setMultipartRequestBody(setPortStats(rawMessage)); break; case OFPMPPORTDESC: builder.setMultipartRequestBody(setPortDesc(rawMessage)); break; case OFPMPQUEUE: builder.setMultipartRequestBody(setQueue(rawMessage)); break; case OFPMPGROUP: builder.setMultipartRequestBody(setGroup(rawMessage)); break; case OFPMPGROUPDESC: builder.setMultipartRequestBody(setGroupDesc(rawMessage)); break; case OFPMPGROUPFEATURES: builder.setMultipartRequestBody(setGroupFeatures(rawMessage)); break; case OFPMPMETER: builder.setMultipartRequestBody(setMeter(rawMessage)); break; case OFPMPMETERCONFIG: builder.setMultipartRequestBody(setMeterConfig(rawMessage)); break; case OFPMPMETERFEATURES: builder.setMultipartRequestBody(setMeterFeatures(rawMessage)); break; case OFPMPEXPERIMENTER: builder.setMultipartRequestBody(setExperimenter(rawMessage)); break; default: break; } return builder.build(); }
From source file:org.opendaylight.netide.openflowjava.protocol.impl.deserialization.factories.MultipartRequestInputMessageFactory.java
License:Open Source License
private MultipartRequestTableFeaturesCase setTableFeatures(ByteBuf input) { MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder(); MultipartRequestTableFeaturesBuilder tableFeaturesBuilder = new MultipartRequestTableFeaturesBuilder(); 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_REQUEST_TABLE_FEATURES); featuresBuilder.setName(ByteBufUtils.decodeNullTerminatedString(input, MAX_TABLE_NAME_LENGTH)); byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(metadataMatch);// w ww .j a v a2s . c o m featuresBuilder.setMetadataMatch(new BigInteger(1, metadataMatch)); byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(metadataWrite); featuresBuilder.setMetadataWrite(new BigInteger(1, metadataWrite)); featuresBuilder.setConfig(createTableConfig(input.readUnsignedInt())); featuresBuilder.setMaxEntries(input.readUnsignedInt()); featuresBuilder.setTableFeatureProperties(createTableFeaturesProperties(input, length - MULTIPART_REQUEST_TABLE_FEATURES_STRUCTURE_LENGTH)); features.add(featuresBuilder.build()); } tableFeaturesBuilder.setTableFeatures(features); caseBuilder.setMultipartRequestTableFeatures(tableFeaturesBuilder.build()); return caseBuilder.build(); }
From source file:org.opendaylight.netide.openflowjava.protocol.impl.deserialization.factories.MultipartRequestInputMessageFactory.java
License:Open Source License
private List<TableFeatureProperties> createTableFeaturesProperties(ByteBuf input, int length) { List<TableFeatureProperties> properties = new ArrayList<>(); int tableFeaturesLength = length; while (tableFeaturesLength > 0) { int propStartIndex = input.readerIndex(); TableFeaturePropertiesBuilder builder = new TableFeaturePropertiesBuilder(); TableFeaturesPropType type = TableFeaturesPropType.forValue(input.readUnsignedShort()); builder.setType(type);//w w w. j a va2 s. c o 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(); CodeKeyMaker keyMaker = CodeKeyMakerFactory .createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID); List<Instruction> instructions = ListDeserializer.deserializeHeaders( EncodeConstants.OF13_VERSION_ID, propertyLength - COMMON_PROPERTY_LENGTH, input, keyMaker, registry); insBuilder.setInstruction(instructions); 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(); CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); List<Action> actions = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, propertyLength - COMMON_PROPERTY_LENGTH, input, keyMaker, registry); actionBuilder.setAction(actions); 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(); CodeKeyMaker keyMaker = CodeKeyMakerFactory .createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); List<MatchEntry> entries = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, propertyLength - COMMON_PROPERTY_LENGTH, input, keyMaker, registry); oxmBuilder.setMatchEntry(entries); builder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); } else if (type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTER) || type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS)) { long expId = input.readUnsignedInt(); input.readerIndex(propStartIndex); OFDeserializer<TableFeatureProperties> propDeserializer = registry .getDeserializer(ExperimenterDeserializerKeyFactory .createMultipartReplyTFDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId)); TableFeatureProperties expProp = propDeserializer.deserialize(input); properties.add(expProp); continue; } if (paddingRemainder != 0) { input.skipBytes(EncodeConstants.PADDING - paddingRemainder); tableFeaturesLength -= EncodeConstants.PADDING - paddingRemainder; } properties.add(builder.build()); } return properties; }
From source file:org.opendaylight.netide.openflowjava.protocol.impl.deserialization.factories.MultipartRequestInputMessageFactory.java
License:Open Source License
private MultipartRequestFlowCase setFlow(ByteBuf input) { MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder(); MultipartRequestFlowBuilder flowBuilder = new MultipartRequestFlowBuilder(); flowBuilder.setTableId(input.readUnsignedByte()); input.skipBytes(FLOW_PADDING_1);/*w w w . java 2s. c om*/ flowBuilder.setOutPort(input.readUnsignedInt()); flowBuilder.setOutGroup(input.readUnsignedInt()); input.skipBytes(FLOW_PADDING_2); byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(cookie); flowBuilder.setCookie(new BigInteger(1, cookie)); byte[] cookie_mask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(cookie_mask); flowBuilder.setCookieMask(new BigInteger(1, cookie_mask)); OFDeserializer<Match> matchDeserializer = registry.getDeserializer( new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class)); flowBuilder.setMatch(matchDeserializer.deserialize(input)); caseBuilder.setMultipartRequestFlow(flowBuilder.build()); return caseBuilder.build(); }
From source file:org.opendaylight.netide.openflowjava.protocol.impl.deserialization.factories.MultipartRequestInputMessageFactory.java
License:Open Source License
private MultipartRequestAggregateCase setAggregate(ByteBuf input) { MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder(); MultipartRequestAggregateBuilder aggregateBuilder = new MultipartRequestAggregateBuilder(); aggregateBuilder.setTableId(input.readUnsignedByte()); input.skipBytes(AGGREGATE_PADDING_1); aggregateBuilder.setOutPort(input.readUnsignedInt()); aggregateBuilder.setOutGroup(input.readUnsignedInt()); input.skipBytes(AGGREGATE_PADDING_2); byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(cookie);//from w w w.j a v a2 s . com aggregateBuilder.setCookie(new BigInteger(1, cookie)); byte[] cookie_mask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(cookie_mask); aggregateBuilder.setCookieMask(new BigInteger(1, cookie_mask)); OFDeserializer<Match> matchDeserializer = registry.getDeserializer( new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class)); aggregateBuilder.setMatch(matchDeserializer.deserialize(input)); caseBuilder.setMultipartRequestAggregate(aggregateBuilder.build()); return caseBuilder.build(); }
From source file:org.opendaylight.netide.openflowjava.protocol.impl.deserialization.factories.MultipartRequestInputMessageFactory.java
License:Open Source License
private MultipartRequestPortStatsCase setPortStats(ByteBuf input) { MultipartRequestPortStatsCaseBuilder caseBuilder = new MultipartRequestPortStatsCaseBuilder(); MultipartRequestPortStatsBuilder portBuilder = new MultipartRequestPortStatsBuilder(); portBuilder.setPortNo(input.readUnsignedInt()); caseBuilder.setMultipartRequestPortStats(portBuilder.build()); return caseBuilder.build(); }
From source file:org.opendaylight.netide.openflowjava.protocol.impl.deserialization.factories.MultipartRequestInputMessageFactory.java
License:Open Source License
private MultipartRequestQueueCase setQueue(ByteBuf input) { MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder(); MultipartRequestQueueBuilder queueBuilder = new MultipartRequestQueueBuilder(); queueBuilder.setPortNo(input.readUnsignedInt()); queueBuilder.setQueueId(input.readUnsignedInt()); caseBuilder.setMultipartRequestQueue(queueBuilder.build()); return caseBuilder.build(); }
From source file:org.opendaylight.netide.openflowjava.protocol.impl.deserialization.factories.MultipartRequestInputMessageFactory.java
License:Open Source License
private MultipartRequestGroupCase setGroup(ByteBuf input) { MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder(); MultipartRequestGroupBuilder groupBuilder = new MultipartRequestGroupBuilder(); groupBuilder.setGroupId(new GroupId(input.readUnsignedInt())); caseBuilder.setMultipartRequestGroup(groupBuilder.build()); return caseBuilder.build(); }
From source file:org.opendaylight.netide.openflowjava.protocol.impl.deserialization.factories.MultipartRequestInputMessageFactory.java
License:Open Source License
private MultipartRequestMeterCase setMeter(ByteBuf input) { MultipartRequestMeterCaseBuilder caseBuilder = new MultipartRequestMeterCaseBuilder(); MultipartRequestMeterBuilder meterBuilder = new MultipartRequestMeterBuilder(); meterBuilder.setMeterId(new MeterId(input.readUnsignedInt())); caseBuilder.setMultipartRequestMeter(meterBuilder.build()); return caseBuilder.build(); }