- private static int computeTableFeaturesLength(MultipartRequestTableFeatures body) {
- int length = 0;
- if (body != null && body.getTableFeatures() != null) {
- List<TableFeatures> tableFeatures = body.getTableFeatures();
- for (TableFeatures feature : tableFeatures) {
- length += computeSingleTableFeatureLength(feature);
- }
- }
- return length;
- }
-
- private static int computeSingleTableFeatureLength(TableFeatures feature) {
- return TABLE_FEATURES_LENGTH + computeTableFeatPropsLength(feature);
- }
-
- private static int computeTableFeatPropsLength(TableFeatures feature) {
- int length = 0;
- List<TableFeatureProperties> featureProperties = feature.getTableFeatureProperties();
- if (featureProperties != null) {
- for (TableFeatureProperties featProp : featureProperties) {
- length += TABLE_FEAT_HEADER_LENGTH;
- if (featProp.getAugmentation(InstructionRelatedTableFeatureProperty.class) != null) {
- InstructionRelatedTableFeatureProperty property =
- featProp.getAugmentation(InstructionRelatedTableFeatureProperty.class);
- length += property.getInstruction().size() * STRUCTURE_HEADER_LENGTH;
- length += paddingNeeded(length);
- } else if (featProp.getAugmentation(NextTableRelatedTableFeatureProperty.class) != null) {
- NextTableRelatedTableFeatureProperty property =
- featProp.getAugmentation(NextTableRelatedTableFeatureProperty.class);
- length += property.getNextTableIds().size();
- length += paddingNeeded(length);
- } else if (featProp.getAugmentation(ActionRelatedTableFeatureProperty.class) != null) {
- ActionRelatedTableFeatureProperty property =
- featProp.getAugmentation(ActionRelatedTableFeatureProperty.class);
- length += property.getAction().size() * STRUCTURE_HEADER_LENGTH;
- length += paddingNeeded(length);
- } else if (featProp.getAugmentation(OxmRelatedTableFeatureProperty.class) != null) {
- OxmRelatedTableFeatureProperty property =
- featProp.getAugmentation(OxmRelatedTableFeatureProperty.class);
- length += property.getMatchEntries().size() * STRUCTURE_HEADER_LENGTH;
- length += paddingNeeded(length);
- } else if (featProp.getAugmentation(ExperimenterRelatedTableFeatureProperty.class) != null) {
- ExperimenterRelatedTableFeatureProperty property =
- featProp.getAugmentation(ExperimenterRelatedTableFeatureProperty.class);
- length += 2 * (EncodeConstants.SIZE_OF_INT_IN_BYTES);
- if (property.getData() != null) {
- length += property.getData().length;
- }
- length += paddingNeeded(length);
- }
- }
- }
- return length;
+ private void serializeExperimenterBody(final MultipartRequestInput message,
+ final ByteBuf outBuffer) {
+ MultipartRequestExperimenterCase expCase =
+ (MultipartRequestExperimenterCase) message.getMultipartRequestBody();
+ MultipartRequestExperimenter experimenter = expCase.getMultipartRequestExperimenter();
+ long expId = experimenter.getAugmentation(ExperimenterIdMultipartRequest.class).getExperimenter().getValue();
+ OFSerializer<MultipartRequestExperimenterCase> serializer = registry.getSerializer(
+ ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey(
+ EncodeConstants.OF13_VERSION_ID, expId));
+ serializer.serialize(expCase, outBuffer);