Search in sources :

Example 6 with TableFeaturesPropType

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType in project openflowplugin by opendaylight.

the class MultipartReplyTableFeaturesDeserializerTest method writeValues.

private void writeValues(ByteBuf buffer, int propertyType) {
    buffer.clear();
    final int replyIndex = buffer.readerIndex();
    buffer.writeShort(EncodeConstants.EMPTY_LENGTH);
    buffer.writeByte(TABLE_ID);
    buffer.writeZero(PADDING_IN_MULTIPART_REPLY_TABLE_FEATURES);
    buffer.writeZero(MAX_TABLE_NAME_LENGTH);
    buffer.writeLong(METADATA_MATCH);
    buffer.writeLong(METADATA_WRITE);
    buffer.writeInt(TABLE_CONFIG);
    buffer.writeInt(MAX_ENTRIES);
    final int propIndex = buffer.writerIndex();
    buffer.writeShort(propertyType);
    final int propLengthIndex = buffer.writerIndex();
    buffer.writeShort(EncodeConstants.EMPTY_LENGTH);
    TableFeaturesPropType propType = TableFeaturesPropType.forValue(propertyType);
    switch(propType) {
        case OFPTFPTINSTRUCTIONS:
        case OFPTFPTINSTRUCTIONSMISS:
            int instructionStartIndex = buffer.writerIndex();
            buffer.writeShort(InstructionConstants.APPLY_ACTIONS_TYPE);
            int instructionLengthIndex = buffer.writerIndex();
            buffer.writeShort(EncodeConstants.EMPTY_LENGTH);
            buffer.setShort(instructionLengthIndex, buffer.writerIndex() - instructionStartIndex);
            break;
        case OFPTFPTNEXTTABLES:
        case OFPTFPTNEXTTABLESMISS:
            buffer.writeByte(1);
            buffer.writeByte(2);
            break;
        case OFPTFPTWRITEACTIONS:
        case OFPTFPTWRITEACTIONSMISS:
            buffer.writeShort(InstructionConstants.WRITE_ACTIONS_TYPE);
            buffer.writeShort(EncodeConstants.EMPTY_LENGTH);
            break;
        case OFPTFPTAPPLYACTIONS:
        case OFPTFPTAPPLYACTIONSMISS:
            buffer.writeShort(InstructionConstants.APPLY_ACTIONS_TYPE);
            buffer.writeShort(EncodeConstants.EMPTY_LENGTH);
            break;
        case OFPTFPTMATCH:
            buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
            buffer.writeByte(OxmMatchConstants.ARP_OP << 1);
            buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
            break;
        case OFPTFPTWILDCARDS:
            buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
            buffer.writeByte(OxmMatchConstants.ARP_SHA << 1);
            buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
            break;
        case OFPTFPTWRITESETFIELD:
            buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
            buffer.writeByte(OxmMatchConstants.ARP_SPA << 1);
            buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
            break;
        case OFPTFPTWRITESETFIELDMISS:
            buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
            buffer.writeByte(OxmMatchConstants.ARP_THA << 1);
            buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
            break;
        case OFPTFPTAPPLYSETFIELD:
            buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
            buffer.writeByte(OxmMatchConstants.ARP_TPA << 1);
            buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
            break;
        case OFPTFPTAPPLYSETFIELDMISS:
            buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
            buffer.writeByte(OxmMatchConstants.ETH_TYPE << 1);
            buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
            break;
        default:
            break;
    }
    int propLength = buffer.writerIndex() - propIndex;
    buffer.setShort(propLengthIndex, buffer.writerIndex() - propIndex);
    int paddingRemainder = propLength % EncodeConstants.PADDING;
    int result = 0;
    if (paddingRemainder != 0) {
        result = EncodeConstants.PADDING - paddingRemainder;
    }
    buffer.writeZero(result);
    buffer.setShort(replyIndex, buffer.writerIndex() - replyIndex);
}
Also used : TableFeaturesPropType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType)

Example 7 with TableFeaturesPropType

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactory method createTableFeaturesProperties.

private List<TableFeatureProperties> createTableFeaturesProperties(final ByteBuf input, final 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);
        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;
}
Also used : TableFeaturesPropType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) NextTableIdsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIdsBuilder) OxmRelatedTableFeatureProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeatureProperty) TableFeatureProperties(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties) ArrayList(java.util.ArrayList) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction) NextTableRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder) NextTableRelatedTableFeatureProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty) InstructionRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder) ActionRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder) TableFeaturePropertiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder) CodeKeyMaker(org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker) BucketsList(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList) ArrayList(java.util.ArrayList) List(java.util.List) OxmRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder)

Example 8 with TableFeaturesPropType

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType in project openflowplugin by opendaylight.

the class TableFeaturesConvertor method setSetFieldTableFeatureProperty.

private static void setSetFieldTableFeatureProperty(final TableFeaturePropertiesBuilder builder, final TableFeaturesPropType type, final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch> setFields) {
    List<MatchEntry> matchEntriesList = new ArrayList<>();
    for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch currMatch : setFields) {
        Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField> currMatchType = currMatch.getMatchType();
        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
        Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField> ofTableFeatureClass = SAL_TO_OF_TABLE_FEATURES.get(currMatchType);
        setMatchEntry(matchEntryBuilder, ofTableFeatureClass, currMatch.isHasMask());
        matchEntriesList.add(matchEntryBuilder.build());
    }
    OxmRelatedTableFeaturePropertyBuilder propBuilder = new OxmRelatedTableFeaturePropertyBuilder();
    propBuilder.setMatchEntry(matchEntriesList);
    builder.setType(type);
    builder.addAugmentation(OxmRelatedTableFeatureProperty.class, propBuilder.build());
}
Also used : MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) ArrayList(java.util.ArrayList) MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) OxmRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder)

Example 9 with TableFeaturesPropType

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType in project openflowplugin by opendaylight.

the class TableFeaturesResponseConvertor method toTableProperties.

private static TableProperties toTableProperties(final List<TableFeatureProperties> ofTablePropertiesList) {
    if (ofTablePropertiesList == null) {
        return new TablePropertiesBuilder().setTableFeatureProperties(Collections.emptyList()).build();
    }
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties> salTablePropertiesList = new ArrayList<>();
    TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
    int index = 0;
    for (TableFeatureProperties property : ofTablePropertiesList) {
        TableFeaturesPropType propType = property.getType();
        ActionExecutor actionExecutor = TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.get(propType);
        if (actionExecutor != null) {
            actionExecutor.execute(property, propBuilder);
        } else {
            LOG.error("Unsupported table feature property : " + propType);
        }
        propBuilder.setOrder(index);
        salTablePropertiesList.add(propBuilder.build());
        index += 1;
    }
    return new TablePropertiesBuilder().setTableFeatureProperties(salTablePropertiesList).build();
}
Also used : TableFeaturesPropType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType) TableFeatureProperties(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties) ArrayList(java.util.ArrayList) TableFeaturePropertiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder) TablePropertiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder)

Aggregations

ArrayList (java.util.ArrayList)8 TableFeaturesPropType (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType)5 ActionRelatedTableFeaturePropertyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder)3 InstructionRelatedTableFeaturePropertyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder)3 NextTableRelatedTableFeaturePropertyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder)3 OxmRelatedTableFeaturePropertyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder)3 NextTableIdsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIdsBuilder)3 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)3 List (java.util.List)2 CodeKeyMaker (org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker)2 NextTableRelatedTableFeatureProperty (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty)2 OxmRelatedTableFeatureProperty (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeatureProperty)2 TableFeatureProperties (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties)2 CopyTtlInCase (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase)1 CopyTtlOutCase (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCase)1 DecMplsTtlCase (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCase)1 DecNwTtlCase (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCase)1 GroupActionCase (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase)1 OutputActionCase (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase)1 PopMplsActionCase (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCase)1