import java.util.ArrayList;
import java.util.List;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
-import org.opendaylight.openflowjava.protocol.impl.util.ActionsDeserializer;
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
-import org.opendaylight.openflowjava.protocol.impl.util.InstructionsDeserializer;
-import org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker;
+import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory;
+import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeatureProperty;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeaturePropertyBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeatureProperty;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeaturePropertyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeatureProperty;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeaturePropertyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeaturePropertyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIds;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIdsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.BucketsList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.BucketsListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsListBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenterBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenterBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlowBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStatsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeaturesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.TableFeatureProperties;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.TableFeaturePropertiesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder;
/**
* Translates MultipartReply messages
* @author timotej.kubas
* @author michal.polkorab
*/
-public class MultipartReplyMessageFactory implements OFDeserializer<MultipartReplyMessage> {
+public class MultipartReplyMessageFactory implements OFDeserializer<MultipartReplyMessage>,
+ DeserializerRegistryInjector {
private static final byte PADDING_IN_MULTIPART_REPLY_HEADER = 4;
private static final int DESC_STR_LEN = 256;
private static final byte PADDING_IN_BUCKETS_HEADER = 4;
private static final byte GROUP_DESC_HEADER_LENGTH = 8;
private static final byte BUCKETS_HEADER_LENGTH = 16;
-
-
- private static MultipartReplyMessageFactory instance;
-
- private MultipartReplyMessageFactory() {
- // singleton
- }
-
- /**
- * @return singleton factory
- */
- public static synchronized MultipartReplyMessageFactory getInstance() {
- if (instance == null){
- instance = new MultipartReplyMessageFactory();
- }
- return instance;
- }
+ private DeserializerRegistry registry;
@Override
- public MultipartReplyMessage bufferToMessage(ByteBuf rawMessage, short version) {
+ public MultipartReplyMessage deserialize(ByteBuf rawMessage) {
MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
int type = rawMessage.readUnsignedShort();
builder.setType(MultipartType.forValue(type));
builder.setFlags(new MultipartRequestFlags((rawMessage.readUnsignedShort() & 0x01) != 0));
rawMessage.skipBytes(PADDING_IN_MULTIPART_REPLY_HEADER);
- switch (type) {
- case 0: builder.setMultipartReplyBody(setDesc(rawMessage));
+ switch (MultipartType.forValue(type)) {
+ case OFPMPDESC: builder.setMultipartReplyBody(setDesc(rawMessage));
break;
- case 1: builder.setMultipartReplyBody(setFlow(rawMessage));
+ case OFPMPFLOW: builder.setMultipartReplyBody(setFlow(rawMessage));
break;
- case 2: builder.setMultipartReplyBody(setAggregate(rawMessage));
+ case OFPMPAGGREGATE: builder.setMultipartReplyBody(setAggregate(rawMessage));
break;
- case 3: builder.setMultipartReplyBody(setTable(rawMessage));
- break;
- case 4: builder.setMultipartReplyBody(setPortStats(rawMessage));
+ case OFPMPTABLE: builder.setMultipartReplyBody(setTable(rawMessage));
break;
- case 5: builder.setMultipartReplyBody(setQueue(rawMessage));
- break;
- case 6: builder.setMultipartReplyBody(setGroup(rawMessage));
+ case OFPMPPORTSTATS: builder.setMultipartReplyBody(setPortStats(rawMessage));
break;
- case 7: builder.setMultipartReplyBody(setGroupDesc(rawMessage));
+ case OFPMPQUEUE: builder.setMultipartReplyBody(setQueue(rawMessage));
break;
- case 8: builder.setMultipartReplyBody(setGroupFeatures(rawMessage));
+ case OFPMPGROUP: builder.setMultipartReplyBody(setGroup(rawMessage));
break;
- case 9: builder.setMultipartReplyBody(setMeter(rawMessage));
+ case OFPMPGROUPDESC: builder.setMultipartReplyBody(setGroupDesc(rawMessage));
break;
- case 10: builder.setMultipartReplyBody(setMeterConfig(rawMessage));
+ case OFPMPGROUPFEATURES: builder.setMultipartReplyBody(setGroupFeatures(rawMessage));
break;
- case 11: builder.setMultipartReplyBody(setMeterFeatures(rawMessage));
+ case OFPMPMETER: builder.setMultipartReplyBody(setMeter(rawMessage));
break;
- case 12: builder.setMultipartReplyBody(setTableFeatures(rawMessage));
+ case OFPMPMETERCONFIG: builder.setMultipartReplyBody(setMeterConfig(rawMessage));
break;
- case 13: builder.setMultipartReplyBody(setPortDesc(rawMessage));
+ case OFPMPMETERFEATURES: builder.setMultipartReplyBody(setMeterFeatures(rawMessage));
break;
- case 0xFFFF: builder.setMultipartReplyBody(setExperimenter(rawMessage));
+ case OFPMPTABLEFEATURES: builder.setMultipartReplyBody(setTableFeatures(rawMessage));
break;
- default:
+ case OFPMPPORTDESC: builder.setMultipartReplyBody(setPortDesc(rawMessage));
+ break;
+ case OFPMPEXPERIMENTER: builder.setMultipartReplyBody(setExperimenter(rawMessage));
+ break;
+ default:
break;
}
-
+
return builder.build();
}
-
+
private static MultipartReplyDescCase setDesc(ByteBuf input) {
MultipartReplyDescCaseBuilder caseBuilder = new MultipartReplyDescCaseBuilder();
MultipartReplyDescBuilder descBuilder = new MultipartReplyDescBuilder();
caseBuilder.setMultipartReplyDesc(descBuilder.build());
return caseBuilder.build();
}
-
- private static MultipartReplyFlowCase setFlow(ByteBuf input) {
+
+ private MultipartReplyFlowCase setFlow(ByteBuf input) {
MultipartReplyFlowCaseBuilder caseBuilder = new MultipartReplyFlowCaseBuilder();
MultipartReplyFlowBuilder flowBuilder = new MultipartReplyFlowBuilder();
List<FlowStats> flowStatsList = new ArrayList<>();
byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
subInput.readBytes(byteCount);
flowStatsBuilder.setByteCount(new BigInteger(1, byteCount));
- flowStatsBuilder.setMatch(MatchDeserializer.createMatch(subInput));
- flowStatsBuilder.setInstructions(InstructionsDeserializer.createInstructions(subInput, subInput.readableBytes()));
+ OFDeserializer<Match> matchDeserializer = registry.getDeserializer(new MessageCodeKey(
+ EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class));
+ flowStatsBuilder.setMatch(matchDeserializer.deserialize(subInput));
+ CodeKeyMaker keyMaker = CodeKeyMakerFactory
+ .createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
+ List<Instruction> instructions = ListDeserializer.deserializeList(
+ EncodeConstants.OF13_VERSION_ID, subInput.readableBytes(), subInput, keyMaker, registry);
+ flowStatsBuilder.setInstruction(instructions);
flowStatsList.add(flowStatsBuilder.build());
}
flowBuilder.setFlowStats(flowStatsList);
caseBuilder.setMultipartReplyFlow(flowBuilder.build());
return caseBuilder.build();
}
-
+
private static FlowModFlags createFlowModFlagsFromBitmap(int input){
- final Boolean _oFPFFSENDFLOWREM = (input & (1 << 0)) != 0;
- final Boolean _oFPFFCHECKOVERLAP = (input & (1 << 1)) != 0;
- final Boolean _oFPFFRESETCOUNTS = (input & (1 << 2)) != 0;
- final Boolean _oFPFFNOPKTCOUNTS = (input & (1 << 3)) != 0;
- final Boolean _oFPFFNOBYTCOUNTS = (input & (1 << 4)) != 0;
- return new FlowModFlags(_oFPFFCHECKOVERLAP, _oFPFFNOBYTCOUNTS, _oFPFFNOPKTCOUNTS, _oFPFFRESETCOUNTS, _oFPFFSENDFLOWREM);
+ final Boolean fmfSENDFLOWREM = (input & (1 << 0)) != 0;
+ final Boolean fmfCHECKOVERLAP = (input & (1 << 1)) != 0;
+ final Boolean fmfRESETCOUNTS = (input & (1 << 2)) != 0;
+ final Boolean fmfNOPKTCOUNTS = (input & (1 << 3)) != 0;
+ final Boolean fmfNOBYTCOUNTS = (input & (1 << 4)) != 0;
+ return new FlowModFlags(fmfCHECKOVERLAP, fmfNOBYTCOUNTS, fmfNOPKTCOUNTS, fmfRESETCOUNTS, fmfSENDFLOWREM);
}
-
+
private static MultipartReplyAggregateCase setAggregate(ByteBuf input) {
MultipartReplyAggregateCaseBuilder caseBuilder = new MultipartReplyAggregateCaseBuilder();
MultipartReplyAggregateBuilder builder = new MultipartReplyAggregateBuilder();
caseBuilder.setMultipartReplyAggregate(builder.build());
return caseBuilder.build();
}
-
+
private static MultipartReplyTableCase setTable(ByteBuf input) {
MultipartReplyTableCaseBuilder caseBuilder = new MultipartReplyTableCaseBuilder();
MultipartReplyTableBuilder builder = new MultipartReplyTableBuilder();
caseBuilder.setMultipartReplyTable(builder.build());
return caseBuilder.build();
}
-
- private static MultipartReplyTableFeaturesCase setTableFeatures(ByteBuf input) {
+
+ private MultipartReplyTableFeaturesCase setTableFeatures(ByteBuf input) {
MultipartReplyTableFeaturesCaseBuilder caseBuilder = new MultipartReplyTableFeaturesCaseBuilder();
MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();
List<TableFeatures> features = new ArrayList<>();
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());
+ featuresBuilder.setName(ByteBufUtils.decodeNullTerminatedString(input, MAX_TABLE_NAME_LENGTH));
byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(metadataMatch);
featuresBuilder.setMetadataMatch(metadataMatch);
featuresBuilder.setMetadataWrite(metadataWrite);
featuresBuilder.setConfig(createTableConfig(input.readUnsignedInt()));
featuresBuilder.setMaxEntries(input.readUnsignedInt());
- featuresBuilder.setTableFeatureProperties(createTableFeaturesProperties(input,
+ featuresBuilder.setTableFeatureProperties(createTableFeaturesProperties(input,
length - MULTIPART_REPLY_TABLE_FEATURES_STRUCTURE_LENGTH));
features.add(featuresBuilder.build());
}
caseBuilder.setMultipartReplyTableFeatures(builder.build());
return caseBuilder.build();
}
-
+
private static TableConfig createTableConfig(long input) {
boolean deprecated = (input & 3) != 0;
return new TableConfig(deprecated);
}
-
- private static List<TableFeatureProperties> createTableFeaturesProperties(ByteBuf input, int length) {
+
+ 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);
if (type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONS)
|| type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS)) {
InstructionRelatedTableFeaturePropertyBuilder insBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
- insBuilder.setInstructions(InstructionsDeserializer.createInstructionIds(input, propertyLength - COMMON_PROPERTY_LENGTH));
+ 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)) {
|| type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONS)
|| type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS)) {
ActionRelatedTableFeaturePropertyBuilder actionBuilder = new ActionRelatedTableFeaturePropertyBuilder();
- actionBuilder.setActionsList(ActionsDeserializer.createActionIds(input, propertyLength - COMMON_PROPERTY_LENGTH));
+ 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.OFPTFPTAPPLYSETFIELD)
|| type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS)) {
OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
- oxmBuilder.setMatchEntries(MatchDeserializer.createMatchIds(input, propertyLength - COMMON_PROPERTY_LENGTH));
+ CodeKeyMaker keyMaker = CodeKeyMakerFactory
+ .createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID);
+ List<MatchEntries> entries = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID,
+ propertyLength - COMMON_PROPERTY_LENGTH, input, keyMaker, registry);
+ oxmBuilder.setMatchEntries(entries);
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());
+ 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);
}
return properties;
}
-
+
private static MultipartReplyPortStatsCase setPortStats(ByteBuf input) {
MultipartReplyPortStatsCaseBuilder caseBuilder = new MultipartReplyPortStatsCaseBuilder();
MultipartReplyPortStatsBuilder builder = new MultipartReplyPortStatsBuilder();
caseBuilder.setMultipartReplyPortStats(builder.build());
return caseBuilder.build();
}
-
+
private static MultipartReplyQueueCase setQueue(ByteBuf input) {
MultipartReplyQueueCaseBuilder caseBuilder = new MultipartReplyQueueCaseBuilder();
MultipartReplyQueueBuilder builder = new MultipartReplyQueueBuilder();
caseBuilder.setMultipartReplyQueue(builder.build());
return caseBuilder.build();
}
-
+
private static MultipartReplyGroupCase setGroup(ByteBuf input) {
MultipartReplyGroupCaseBuilder caseBuilder = new MultipartReplyGroupCaseBuilder();
MultipartReplyGroupBuilder builder = new MultipartReplyGroupBuilder();
bucketStatsBuilder.setByteCount(new BigInteger(1, byteCountBucket));
bucketStatsList.add(bucketStatsBuilder.build());
actualLength += BUCKET_COUNTER_LENGTH;
- }
+ }
groupStatsBuilder.setBucketStats(bucketStatsList);
groupStatsList.add(groupStatsBuilder.build());
}
caseBuilder.setMultipartReplyGroup(builder.build());
return caseBuilder.build();
}
-
+
private static MultipartReplyMeterFeaturesCase setMeterFeatures(ByteBuf input) {
MultipartReplyMeterFeaturesCaseBuilder caseBuilder = new MultipartReplyMeterFeaturesCaseBuilder();
MultipartReplyMeterFeaturesBuilder builder = new MultipartReplyMeterFeaturesBuilder();
caseBuilder.setMultipartReplyMeterFeatures(builder.build());
return caseBuilder.build();
}
-
+
private static MeterFlags createMeterFlags(long input){
- final Boolean _oFPMFKBPS = (input & (1 << 0)) != 0;
- final Boolean _oFPMFPKTPS = (input & (1 << 1)) != 0;
- final Boolean _oFPMFBURST = (input & (1 << 2)) != 0;
- final Boolean _oFPMFSTATS = (input & (1 << 3)) != 0;
- return new MeterFlags(_oFPMFBURST, _oFPMFKBPS, _oFPMFPKTPS, _oFPMFSTATS);
+ final Boolean mfKBPS = (input & (1 << 0)) != 0;
+ final Boolean mfPKTPS = (input & (1 << 1)) != 0;
+ final Boolean mfBURST = (input & (1 << 2)) != 0;
+ final Boolean mfSTATS = (input & (1 << 3)) != 0;
+ return new MeterFlags(mfBURST, mfKBPS, mfPKTPS, mfSTATS);
}
-
+
private static MeterBandTypeBitmap createMeterBandsBitmap(long input) {
- final Boolean _oFPMBTDROP = (input & (1 << 0)) != 0;
- final Boolean _oFPMBTDSCPREMARK = (input & (1 << 1)) != 0;
- return new MeterBandTypeBitmap(_oFPMBTDROP, _oFPMBTDSCPREMARK);
+ final Boolean mbtDROP = (input & (1 << 1)) != 0;
+ final Boolean mbtDSCPREMARK = (input & (1 << 2)) != 0;
+ return new MeterBandTypeBitmap(mbtDROP, mbtDSCPREMARK);
}
-
+
private static MultipartReplyMeterCase setMeter(ByteBuf input) {
MultipartReplyMeterCaseBuilder caseBuilder = new MultipartReplyMeterCaseBuilder();
MultipartReplyMeterBuilder builder = new MultipartReplyMeterBuilder();
caseBuilder.setMultipartReplyMeter(builder.build());
return caseBuilder.build();
}
-
- private static MultipartReplyMeterConfigCase setMeterConfig(ByteBuf input) {
+
+ private MultipartReplyMeterConfigCase setMeterConfig(ByteBuf input) {
MultipartReplyMeterConfigCaseBuilder caseBuilder = new MultipartReplyMeterConfigCaseBuilder();
MultipartReplyMeterConfigBuilder builder = new MultipartReplyMeterConfigBuilder();
List<MeterConfig> meterConfigList = new ArrayList<>();
int actualLength = METER_CONFIG_LENGTH;
List<Bands> bandsList = new ArrayList<>();
while (actualLength < meterConfigBodyLength) {
+ int bandStartIndex = input.readerIndex();
BandsBuilder bandsBuilder = new BandsBuilder();
int bandType = input.readUnsignedShort();
switch (bandType) {
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());
+ long expId = input.getUnsignedInt(input.readerIndex() + 2 * EncodeConstants.SIZE_OF_INT_IN_BYTES);
+ input.readerIndex(bandStartIndex);
+ OFDeserializer<MeterBandExperimenterCase> deserializer = registry.getDeserializer(
+ ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey(
+ EncodeConstants.OF13_VERSION_ID, expId));
+ bandsBuilder.setMeterBand(deserializer.deserialize(input));
break;
default:
break;
caseBuilder.setMultipartReplyMeterConfig(builder.build());
return caseBuilder.build();
}
-
- private static MultipartReplyExperimenterCase setExperimenter(ByteBuf input) {
- MultipartReplyExperimenterCaseBuilder caseBuilder = new MultipartReplyExperimenterCaseBuilder();
- MultipartReplyExperimenterBuilder builder = new MultipartReplyExperimenterBuilder();
- builder.setExperimenter(input.readUnsignedInt());
- builder.setExpType(input.readUnsignedInt());
- byte[] data = new byte[input.readableBytes()];
- input.readBytes(data);
- builder.setData(data);
- caseBuilder.setMultipartReplyExperimenter(builder.build());
- return caseBuilder.build();
+
+ private MultipartReplyExperimenterCase setExperimenter(ByteBuf input) {
+ return registry.getDeserializer(ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey(
+ EncodeConstants.OF13_VERSION_ID, input.readUnsignedInt()));
}
-
+
private static MultipartReplyPortDescCase setPortDesc(ByteBuf input) {
MultipartReplyPortDescCaseBuilder caseBuilder = new MultipartReplyPortDescCaseBuilder();
MultipartReplyPortDescBuilder builder = new MultipartReplyPortDescBuilder();
caseBuilder.setMultipartReplyPortDesc(builder.build());
return caseBuilder.build();
}
-
+
private static PortConfig createPortConfig(long input){
- final Boolean _portDown = ((input) & (1<<0)) != 0;
- final Boolean _noRecv = ((input) & (1<<2)) != 0;
- final Boolean _noFwd = ((input) & (1<<5)) != 0;
- final Boolean _noPacketIn = ((input) & (1<<6)) != 0;
- return new PortConfig(_noFwd, _noPacketIn, _noRecv, _portDown);
+ final Boolean pcPortDown = ((input) & (1<<0)) != 0;
+ final Boolean pcNRecv = ((input) & (1<<2)) != 0;
+ final Boolean pcNFwd = ((input) & (1<<5)) != 0;
+ final Boolean pcNPacketIn = ((input) & (1<<6)) != 0;
+ return new PortConfig(pcNFwd, pcNPacketIn, pcNRecv, pcPortDown);
}
-
+
private static PortState createPortState(long input){
- final Boolean _linkDown = ((input) & (1<<0)) != 0;
- final Boolean _blocked = ((input) & (1<<1)) != 0;
- final Boolean _live = ((input) & (1<<2)) != 0;
- return new PortState(_blocked, _linkDown, _live);
+ final Boolean psLinkDown = ((input) & (1<<0)) != 0;
+ final Boolean psBlocked = ((input) & (1<<1)) != 0;
+ final Boolean psLive = ((input) & (1<<2)) != 0;
+ return new PortState(psBlocked, psLinkDown, psLive);
}
-
+
private static PortFeatures createPortFeatures(long input){
- final Boolean _10mbHd = ((input) & (1<<0)) != 0;
- final Boolean _10mbFd = ((input) & (1<<1)) != 0;
- final Boolean _100mbHd = ((input) & (1<<2)) != 0;
- final Boolean _100mbFd = ((input) & (1<<3)) != 0;
- final Boolean _1gbHd = ((input) & (1<<4)) != 0;
- final Boolean _1gbFd = ((input) & (1<<5)) != 0;
- final Boolean _10gbFd = ((input) & (1<<6)) != 0;
- final Boolean _40gbFd = ((input) & (1<<7)) != 0;
- final Boolean _100gbFd = ((input) & (1<<8)) != 0;
- final Boolean _1tbFd = ((input) & (1<<9)) != 0;
- final Boolean _other = ((input) & (1<<10)) != 0;
- final Boolean _copper = ((input) & (1<<11)) != 0;
- final Boolean _fiber = ((input) & (1<<12)) != 0;
- final Boolean _autoneg = ((input) & (1<<13)) != 0;
- final Boolean _pause = ((input) & (1<<14)) != 0;
- final Boolean _pauseAsym = ((input) & (1<<15)) != 0;
- return new PortFeatures(_100gbFd, _100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd, _1gbFd,
- _1gbHd, _1tbFd, _40gbFd, _autoneg, _copper, _fiber, _other, _pause, _pauseAsym);
+ final Boolean pf10mbHd = ((input) & (1<<0)) != 0;
+ final Boolean pf10mbFd = ((input) & (1<<1)) != 0;
+ final Boolean pf100mbHd = ((input) & (1<<2)) != 0;
+ final Boolean pf100mbFd = ((input) & (1<<3)) != 0;
+ final Boolean pf1gbHd = ((input) & (1<<4)) != 0;
+ final Boolean pf1gbFd = ((input) & (1<<5)) != 0;
+ final Boolean pf10gbFd = ((input) & (1<<6)) != 0;
+ final Boolean pf40gbFd = ((input) & (1<<7)) != 0;
+ final Boolean pf100gbFd = ((input) & (1<<8)) != 0;
+ final Boolean pf1tbFd = ((input) & (1<<9)) != 0;
+ final Boolean pfOther = ((input) & (1<<10)) != 0;
+ final Boolean pfCopper = ((input) & (1<<11)) != 0;
+ final Boolean pfFiber = ((input) & (1<<12)) != 0;
+ final Boolean pfAutoneg = ((input) & (1<<13)) != 0;
+ final Boolean pfPause = ((input) & (1<<14)) != 0;
+ final Boolean pfPauseAsym = ((input) & (1<<15)) != 0;
+ return new PortFeatures(pf100gbFd, pf100mbFd, pf100mbHd, pf10gbFd, pf10mbFd, pf10mbHd, pf1gbFd,
+ pf1gbHd, pf1tbFd, pf40gbFd, pfAutoneg, pfCopper, pfFiber, pfOther, pfPause, pfPauseAsym);
}
-
+
private static MultipartReplyGroupFeaturesCase setGroupFeatures(ByteBuf rawMessage) {
MultipartReplyGroupFeaturesCaseBuilder caseBuilder = new MultipartReplyGroupFeaturesCaseBuilder();
MultipartReplyGroupFeaturesBuilder featuresBuilder = new MultipartReplyGroupFeaturesBuilder();
caseBuilder.setMultipartReplyGroupFeatures(featuresBuilder.build());
return caseBuilder.build();
}
-
+
private static ActionType createActionBitmap(long input) {
- final Boolean OFPAT_OUTPUT = ((input) & (1<<0)) != 0;
- final Boolean OFPAT_COPY_TTL_OUT = ((input) & (1<<1)) != 0;
- final Boolean OFPAT_COPY_TTL_IN = ((input) & (1<<2)) != 0;
- final Boolean OFPAT_SET_MPLS_TTL = ((input) & (1<<3)) != 0;
- final Boolean OFPAT_DEC_MPLS_TTL = ((input) & (1<<4)) != 0;
- final Boolean OFPAT_PUSH_VLAN = ((input) & (1<<5)) != 0;
- final Boolean OFPAT_POP_VLAN = ((input) & (1<<6)) != 0;
- final Boolean OFPAT_PUSH_MPLS = ((input) & (1<<7)) != 0;
- final Boolean OFPAT_POP_MPLS = ((input) & (1<<8)) != 0;
- final Boolean OFPAT_SET_QUEUE = ((input) & (1<<9)) != 0;
- final Boolean OFPAT_GROUP = ((input) & (1<<10)) != 0;
- final Boolean OFPAT_SET_NW_TTL = ((input) & (1<<11)) != 0;
- final Boolean OFPAT_DEC_NW_TTL = ((input) & (1<<12)) != 0;
- final Boolean OFPAT_SET_FIELD = ((input) & (1<<13)) != 0;
- final Boolean OFPAT_PUSH_PBB = ((input) & (1<<14)) != 0;
- final Boolean OFPAT_POP_PBB = ((input) & (1<<15)) != 0;
- final Boolean OFPAT_EXPERIMENTER = ((input) & (1<<16)) != 0;
- return new ActionType(OFPAT_COPY_TTL_IN, OFPAT_COPY_TTL_OUT, OFPAT_DEC_MPLS_TTL,
- OFPAT_DEC_NW_TTL, OFPAT_EXPERIMENTER, OFPAT_GROUP, OFPAT_OUTPUT, OFPAT_POP_MPLS,
- OFPAT_POP_PBB, OFPAT_POP_VLAN, OFPAT_PUSH_MPLS, OFPAT_PUSH_PBB, OFPAT_PUSH_VLAN,
- OFPAT_SET_FIELD, OFPAT_SET_MPLS_TTL, OFPAT_SET_NW_TTL, OFPAT_SET_QUEUE);
+ final Boolean atOutput = ((input) & (1<<0)) != 0;
+ final Boolean atCopyTTLout = ((input) & (1<<11)) != 0;
+ final Boolean atCopyTTLin = ((input) & (1<<12)) != 0;
+ final Boolean atSetMplsTTL = ((input) & (1<<15)) != 0;
+ final Boolean atDecMplsTTL = ((input) & (1<<16)) != 0;
+ final Boolean atPushVLAN = ((input) & (1<<17)) != 0;
+ final Boolean atPopVLAN = ((input) & (1<<18)) != 0;
+ final Boolean atPushMPLS = ((input) & (1<<19)) != 0;
+ final Boolean atPopMPLS = ((input) & (1<<20)) != 0;
+ final Boolean atSetQueue = ((input) & (1<<21)) != 0;
+ final Boolean atGroup = ((input) & (1<<22)) != 0;
+ final Boolean atSetNWTTL = ((input) & (1<<23)) != 0;
+ final Boolean atDecNWTTL = ((input) & (1<<24)) != 0;
+ final Boolean atSetField = ((input) & (1<<25)) != 0;
+ final Boolean atPushPBB = ((input) & (1<<26)) != 0;
+ final Boolean atPopPBB = ((input) & (1<<27)) != 0;
+ final Boolean atExperimenter = false;
+ return new ActionType(atCopyTTLin, atCopyTTLout, atDecMplsTTL,
+ atDecNWTTL, atExperimenter, atGroup, atOutput, atPopMPLS,
+ atPopPBB, atPopVLAN, atPushMPLS, atPushPBB, atPushVLAN,
+ atSetField, atSetMplsTTL, atSetNWTTL, atSetQueue);
}
private static GroupCapabilities createCapabilities(long input) {
- final Boolean OFOFPGFC_SELECT_WEIGHT = ((input) & (1<<0)) != 0;
- final Boolean OFPGFC_SELECT_LIVENESS = ((input) & (1<<1)) != 0;
- final Boolean OFPGFC_CHAINING = ((input) & (1<<2)) != 0;
- final Boolean OFPGFC_CHAINING_CHECKS = ((input) & (1<<3)) != 0;
- return new GroupCapabilities(OFPGFC_CHAINING, OFPGFC_CHAINING_CHECKS, OFPGFC_SELECT_LIVENESS, OFOFPGFC_SELECT_WEIGHT);
+ final Boolean gcSelectWeight = ((input) & (1<<0)) != 0;
+ final Boolean gcSelectLiveness = ((input) & (1<<1)) != 0;
+ final Boolean gcChaining = ((input) & (1<<2)) != 0;
+ final Boolean gcChainingChecks = ((input) & (1<<3)) != 0;
+ return new GroupCapabilities(gcChaining, gcChainingChecks, gcSelectLiveness, gcSelectWeight);
}
private static GroupTypes createGroupType(long input) {
- final Boolean OFPGT_ALL = ((input) & (1<<0)) != 0;
- final Boolean OFPGT_SELECT = ((input) & (1<<1)) != 0;
- final Boolean OFPGT_INDIRECT = ((input) & (1<<2)) != 0;
- final Boolean OFPGT_FF = ((input) & (1<<3)) != 0;
- return new GroupTypes(OFPGT_ALL, OFPGT_FF, OFPGT_INDIRECT, OFPGT_SELECT);
+ final Boolean gtAll = ((input) & (1<<0)) != 0;
+ final Boolean gtSelect = ((input) & (1<<1)) != 0;
+ final Boolean gtIndirect = ((input) & (1<<2)) != 0;
+ final Boolean gtFF = ((input) & (1<<3)) != 0;
+ return new GroupTypes(gtAll, gtFF, gtIndirect, gtSelect);
}
-
- private static MultipartReplyGroupDescCase setGroupDesc(ByteBuf input) {
+
+ private MultipartReplyGroupDescCase setGroupDesc(ByteBuf input) {
MultipartReplyGroupDescCaseBuilder caseBuilder = new MultipartReplyGroupDescCaseBuilder();
MultipartReplyGroupDescBuilder builder = new MultipartReplyGroupDescBuilder();
List<GroupDesc> groupDescsList = new ArrayList<>();
bucketsBuilder.setWatchPort(new PortNumber(input.readUnsignedInt()));
bucketsBuilder.setWatchGroup(input.readUnsignedInt());
input.skipBytes(PADDING_IN_BUCKETS_HEADER);
- List<ActionsList> actionsList = ActionsDeserializer
- .createActionsList(input, bucketsLength - BUCKETS_HEADER_LENGTH);
- bucketsBuilder.setActionsList(actionsList);
+ CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
+ List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID,
+ bucketsLength - BUCKETS_HEADER_LENGTH, input, keyMaker, registry);
+ bucketsBuilder.setAction(actions);
bucketsList.add(bucketsBuilder.build());
actualLength += bucketsLength;
}
caseBuilder.setMultipartReplyGroupDesc(builder.build());
return caseBuilder.build();
}
-
+
+ @Override
+ public void injectDeserializerRegistry(
+ DeserializerRegistry deserializerRegistry) {
+ registry = deserializerRegistry;
+ }
}