Search in sources :

Example 6 with MultipartReplyBody

use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.

the class MultipartReplyTableFeaturesDeserializer method deserialize.

@Override
public MultipartReplyBody deserialize(ByteBuf message) {
    final MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();
    final List<TableFeatures> items = new ArrayList<>();
    while (message.readableBytes() > 0) {
        final int itemLength = message.readUnsignedShort();
        final TableFeaturesBuilder itemBuilder = new TableFeaturesBuilder().setTableId(message.readUnsignedByte());
        message.skipBytes(PADDING_IN_MULTIPART_REPLY_TABLE_FEATURES);
        final String name = ByteBufUtils.decodeNullTerminatedString(message, MAX_TABLE_NAME_LENGTH);
        final byte[] match = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        message.readBytes(match);
        final byte[] write = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        message.readBytes(write);
        items.add(itemBuilder.setKey(new TableFeaturesKey(itemBuilder.getTableId())).setName(name).setMetadataMatch(new BigInteger(1, match)).setMetadataWrite(new BigInteger(1, write)).setConfig(readTableConfig(message)).setMaxEntries(message.readUnsignedInt()).setTableProperties(readTableProperties(message, itemLength - MULTIPART_REPLY_TABLE_FEATURES_STRUCTURE_LENGTH)).build());
    }
    return builder.setTableFeatures(items).build();
}
Also used : TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures) TableFeaturesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey) ArrayList(java.util.ArrayList) TableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesBuilder) BigInteger(java.math.BigInteger) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesBuilder)

Example 7 with MultipartReplyBody

use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.

the class MultipartReplyTranslatorUtil method translate.

public static Optional<? extends MultipartReplyBody> translate(final OfHeader message, final DeviceInfo deviceInfo, @Nullable final ConvertorExecutor convertorExecutor, @Nullable final TranslatorLibrary translatorLibrary) {
    if (message instanceof MultipartReply) {
        final Optional<ConvertorExecutor> convertor = Optional.ofNullable(convertorExecutor);
        final Optional<TranslatorLibrary> translator = Optional.ofNullable(translatorLibrary);
        final MultipartReply msg = MultipartReply.class.cast(message);
        final OpenflowVersion ofVersion = OpenflowVersion.get(deviceInfo.getVersion());
        final VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(deviceInfo.getVersion());
        data.setDatapathId(deviceInfo.getDatapathId());
        switch(msg.getType()) {
            case OFPMPFLOW:
                return convertor.flatMap(c -> Optional.of(translateFlow(msg, data, c)));
            case OFPMPAGGREGATE:
                return Optional.of(translateAggregate(msg));
            case OFPMPPORTSTATS:
                return Optional.of(translatePortStats(msg, ofVersion, deviceInfo.getDatapathId()));
            case OFPMPGROUP:
                return convertor.flatMap(c -> Optional.of(translateGroup(msg, data, c)));
            case OFPMPGROUPDESC:
                return convertor.flatMap(c -> Optional.of(translateGroupDesc(msg, data, c)));
            case OFPMPGROUPFEATURES:
                return Optional.of(translateGroupFeatures(msg));
            case OFPMPMETER:
                return convertor.flatMap(c -> Optional.of(translateMeter(msg, data, c)));
            case OFPMPMETERCONFIG:
                return convertor.flatMap(c -> Optional.of(translateMeterConfig(msg, data, c)));
            case OFPMPMETERFEATURES:
                return Optional.of(translateMeterFeatures(msg));
            case OFPMPTABLE:
                return Optional.of(translateTable(msg));
            case OFPMPQUEUE:
                return Optional.of(translateQueue(msg, ofVersion, deviceInfo.getDatapathId()));
            case OFPMPDESC:
                return Optional.of(translateDesc(msg));
            case OFPMPTABLEFEATURES:
                return convertor.flatMap(c -> Optional.of(translateTableFeatures(msg, deviceInfo.getVersion(), c)));
            case OFPMPPORTDESC:
                return translator.flatMap(t -> Optional.of(translatePortDesc(msg, deviceInfo, t)));
            default:
        }
    } else if (message instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply) {
        return Optional.of(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply.class.cast(message).getMultipartReplyBody());
    }
    LOG.debug("Failed to translate {} for node {}.", message.getImplementedInterface(), deviceInfo);
    return Optional.empty();
}
Also used : VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) OpenflowVersion(org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) TranslatorLibrary(org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary) ConvertorExecutor(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor)

Example 8 with MultipartReplyBody

use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactory method serializeTableFeaturesBody.

private void serializeTableFeaturesBody(final MultipartReplyBody body, final ByteBuf outBuffer) {
    MultipartReplyTableFeaturesCase tableFeaturesCase = (MultipartReplyTableFeaturesCase) body;
    MultipartReplyTableFeatures tableFeatures = tableFeaturesCase.getMultipartReplyTableFeatures();
    for (TableFeatures tableFeature : tableFeatures.getTableFeatures()) {
        ByteBuf tableFeatureBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
        tableFeatureBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
        tableFeatureBuff.writeByte(tableFeature.getTableId());
        tableFeatureBuff.writeZero(TABLE_FEATURES_PADDING);
        write32String(tableFeature.getName(), tableFeatureBuff);
        tableFeatureBuff.writeBytes(tableFeature.getMetadataMatch());
        tableFeatureBuff.writeZero(64 - tableFeature.getMetadataMatch().length);
        tableFeatureBuff.writeBytes(tableFeature.getMetadataWrite());
        tableFeatureBuff.writeZero(64 - tableFeature.getMetadataWrite().length);
        writeTableConfig(tableFeature.getConfig(), tableFeatureBuff);
        tableFeatureBuff.writeInt(tableFeature.getMaxEntries().intValue());
        for (TableFeatureProperties tableFeatureProp : tableFeature.getTableFeatureProperties()) {
            switch(tableFeatureProp.getType()) {
                case OFPTFPTINSTRUCTIONS:
                    writeInstructionRelatedTableProperty(tableFeatureBuff, tableFeatureProp, INSTRUCTIONS_CODE);
                    break;
                case OFPTFPTINSTRUCTIONSMISS:
                    writeInstructionRelatedTableProperty(tableFeatureBuff, tableFeatureProp, INSTRUCTIONS_MISS_CODE);
                    break;
                case OFPTFPTNEXTTABLES:
                    writeNextTableRelatedTableProperty(tableFeatureBuff, tableFeatureProp, NEXT_TABLE_CODE);
                    break;
                case OFPTFPTNEXTTABLESMISS:
                    writeNextTableRelatedTableProperty(tableFeatureBuff, tableFeatureProp, NEXT_TABLE_MISS_CODE);
                    break;
                case OFPTFPTWRITEACTIONS:
                    writeActionsRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WRITE_ACTIONS_CODE);
                    break;
                case OFPTFPTWRITEACTIONSMISS:
                    writeActionsRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WRITE_ACTIONS_MISS_CODE);
                    break;
                case OFPTFPTAPPLYACTIONS:
                    writeActionsRelatedTableProperty(tableFeatureBuff, tableFeatureProp, APPLY_ACTIONS_CODE);
                    break;
                case OFPTFPTAPPLYACTIONSMISS:
                    writeActionsRelatedTableProperty(tableFeatureBuff, tableFeatureProp, APPLY_ACTIONS_MISS_CODE);
                    break;
                case OFPTFPTMATCH:
                    writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, MATCH_CODE);
                    break;
                case OFPTFPTWILDCARDS:
                    writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WILDCARDS_CODE);
                    break;
                case OFPTFPTWRITESETFIELD:
                    writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WRITE_SETFIELD_CODE);
                    break;
                case OFPTFPTWRITESETFIELDMISS:
                    writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WRITE_SETFIELD_MISS_CODE);
                    break;
                case OFPTFPTAPPLYSETFIELD:
                    writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, APPLY_SETFIELD_CODE);
                    break;
                case OFPTFPTAPPLYSETFIELDMISS:
                    writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, APPLY_SETFIELD_MISS_CODE);
                    break;
                case OFPTFPTEXPERIMENTER:
                case OFPTFPTEXPERIMENTERMISS:
                    writeExperimenterRelatedTableProperty(tableFeatureBuff, tableFeatureProp);
                    break;
                default:
                    break;
            }
        }
        tableFeatureBuff.setShort(TABLE_FEATURES_LENGTH_INDEX, tableFeatureBuff.readableBytes());
        outBuffer.writeBytes(tableFeatureBuff);
    }
}
Also used : MultipartReplyTableFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase) MultipartReplyTableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures) TableFeatures(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) TableFeatureProperties(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties) ByteBuf(io.netty.buffer.ByteBuf) MultipartReplyTableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures)

Example 9 with MultipartReplyBody

use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactory method serializeFlowBody.

private void serializeFlowBody(final MultipartReplyBody body, final ByteBuf outBuffer, final MultipartReplyMessage message) {
    MultipartReplyFlowCase flowCase = (MultipartReplyFlowCase) body;
    MultipartReplyFlow flow = flowCase.getMultipartReplyFlow();
    for (FlowStats flowStats : flow.getFlowStats()) {
        ByteBuf flowStatsBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
        flowStatsBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
        flowStatsBuff.writeByte((byte) flowStats.getTableId().longValue());
        flowStatsBuff.writeZero(FLOW_STATS_PADDING_1);
        flowStatsBuff.writeInt(flowStats.getDurationSec().intValue());
        flowStatsBuff.writeInt(flowStats.getDurationNsec().intValue());
        flowStatsBuff.writeShort(flowStats.getPriority());
        flowStatsBuff.writeShort(flowStats.getIdleTimeout());
        flowStatsBuff.writeShort(flowStats.getHardTimeout());
        flowStatsBuff.writeZero(FLOW_STATS_PADDING_2);
        flowStatsBuff.writeLong(flowStats.getCookie().longValue());
        flowStatsBuff.writeLong(flowStats.getPacketCount().longValue());
        flowStatsBuff.writeLong(flowStats.getByteCount().longValue());
        OFSerializer<Match> matchSerializer = registry.<Match, OFSerializer<Match>>getSerializer(new MessageTypeKey<>(message.getVersion(), Match.class));
        matchSerializer.serialize(flowStats.getMatch(), flowStatsBuff);
        ListSerializer.serializeList(flowStats.getInstruction(), TypeKeyMakerFactory.createInstructionKeyMaker(message.getVersion()), registry, flowStatsBuff);
        flowStatsBuff.setShort(FLOW_STATS_LENGTH_INDEX, flowStatsBuff.readableBytes());
        outBuffer.writeBytes(flowStatsBuff);
    }
}
Also used : FlowStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats) OFSerializer(org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer) MultipartReplyFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow) MultipartReplyFlowCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase) ByteBuf(io.netty.buffer.ByteBuf) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match)

Example 10 with MultipartReplyBody

use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactory method serializeQueueBody.

private void serializeQueueBody(final MultipartReplyBody body, final ByteBuf outBuffer) {
    MultipartReplyQueueCase queueCase = (MultipartReplyQueueCase) body;
    MultipartReplyQueue queue = queueCase.getMultipartReplyQueue();
    for (QueueStats queueStats : queue.getQueueStats()) {
        outBuffer.writeInt(queueStats.getPortNo().intValue());
        outBuffer.writeInt(queueStats.getQueueId().intValue());
        outBuffer.writeLong(queueStats.getTxBytes().longValue());
        outBuffer.writeLong(queueStats.getTxPackets().longValue());
        outBuffer.writeLong(queueStats.getTxErrors().longValue());
        outBuffer.writeInt(queueStats.getDurationSec().intValue());
        outBuffer.writeInt(queueStats.getDurationNsec().intValue());
    }
}
Also used : MultipartReplyQueueCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase) QueueStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats) MultipartReplyQueue(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue)

Aggregations

ArrayList (java.util.ArrayList)11 ByteBuf (io.netty.buffer.ByteBuf)9 BigInteger (java.math.BigInteger)8 Counter32 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32)7 Counter64 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64)6 BucketId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId)2 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)2 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)2 MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId)2 DurationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder)2 MultipartReplyAggregateCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase)2 MultipartReplyFlowCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase)2 MultipartReplyTableCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase)2 MultipartReplyAggregate (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate)2 MultipartReplyFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow)2 FlowStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats)2 MultipartReplyTable (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable)2 TableStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats)2 List (java.util.List)1 OFDeserializer (org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer)1