Search in sources :

Example 56 with Message

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message in project openflowplugin by opendaylight.

the class MultipartReplyTranslatorUtil method translateMeterFeatures.

private static org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterFeatures translateMeterFeatures(final MultipartReply msg) {
    MultipartReplyMeterFeaturesBuilder message = new MultipartReplyMeterFeaturesBuilder();
    MultipartReplyMeterFeaturesCase caseBody = (MultipartReplyMeterFeaturesCase) msg.getMultipartReplyBody();
    MultipartReplyMeterFeatures replyBody = caseBody.getMultipartReplyMeterFeatures();
    message.setMaxBands(replyBody.getMaxBands());
    message.setMaxColor(replyBody.getMaxColor());
    message.setMaxMeter(new Counter32(replyBody.getMaxMeter()));
    List<Class<? extends MeterCapability>> supportedCapabilities = new ArrayList<>();
    if (replyBody.getCapabilities().isOFPMFBURST()) {
        supportedCapabilities.add(MeterBurst.class);
    }
    if (replyBody.getCapabilities().isOFPMFKBPS()) {
        supportedCapabilities.add(MeterKbps.class);
    }
    if (replyBody.getCapabilities().isOFPMFPKTPS()) {
        supportedCapabilities.add(MeterPktps.class);
    }
    if (replyBody.getCapabilities().isOFPMFSTATS()) {
        supportedCapabilities.add(MeterStats.class);
    }
    message.setMeterCapabilitiesSupported(supportedCapabilities);
    List<Class<? extends MeterBand>> supportedMeterBand = new ArrayList<>();
    if (replyBody.getBandTypes().isOFPMBTDROP()) {
        supportedMeterBand.add(MeterBandDrop.class);
    }
    if (replyBody.getBandTypes().isOFPMBTDSCPREMARK()) {
        supportedMeterBand.add(MeterBandDscpRemark.class);
    }
    message.setMeterBandSupported(supportedMeterBand);
    return message.build();
}
Also used : Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) MeterBand(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBand) MultipartReplyMeterFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesBuilder) MultipartReplyMeterFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures) ArrayList(java.util.ArrayList) MeterCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterCapability) MultipartReplyMeterFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase)

Example 57 with Message

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message 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 58 with Message

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message in project openflowplugin by opendaylight.

the class HandshakeManagerImpl method sendHelloMessage.

/**
 * send hello reply without versionBitmap.
 *
 * @param helloVersion initial hello version for openflow connection negotiation
 * @param helloXid     transaction id
 */
private ListenableFuture<Void> sendHelloMessage(Short helloVersion, final Long helloXid) throws Exception {
    HelloInput helloInput = MessageFactory.createHelloInput(helloVersion, helloXid, versionOrder);
    final SettableFuture<Void> resultFtr = SettableFuture.create();
    LOG.debug("sending hello message: version{}, xid={}, version bitmap={}", helloVersion, helloXid, MessageFactory.digVersions(helloInput.getElements()));
    Future<RpcResult<Void>> helloResult = connectionAdapter.hello(helloInput);
    ListenableFuture<RpcResult<Void>> rpcResultListenableFuture = JdkFutureAdapters.listenInPoolThread(helloResult);
    Futures.addCallback(rpcResultListenableFuture, new FutureCallback<RpcResult<Void>>() {

        @Override
        public void onSuccess(@Nonnull RpcResult<Void> result) {
            if (result.isSuccessful()) {
                LOG.debug("hello successfully sent, xid={}, addr={}", helloXid, connectionAdapter.getRemoteAddress());
                resultFtr.set(null);
            } else {
                for (RpcError error : result.getErrors()) {
                    LOG.debug("hello sending failed [{}]: i:{} s:{} m:{}, addr:{}", helloXid, error.getInfo(), error.getSeverity(), error.getMessage(), connectionAdapter.getRemoteAddress());
                    if (error.getCause() != null) {
                        LOG.trace("DETAIL of sending hello failure", error.getCause());
                    }
                }
                resultFtr.cancel(false);
                handshakeListener.onHandshakeFailure();
            }
        }

        @Override
        public void onFailure(Throwable throwable) {
            LOG.warn("sending of hello failed seriously [{}, addr:{}]: {}", helloXid, connectionAdapter.getRemoteAddress(), throwable.getMessage());
            LOG.trace("DETAIL of sending of hello failure:", throwable);
            resultFtr.cancel(false);
            handshakeListener.onHandshakeFailure();
        }
    }, MoreExecutors.directExecutor());
    LOG.trace("sending hello message [{}] - result hooked ..", helloXid);
    return resultFtr;
}
Also used : HelloInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) RpcError(org.opendaylight.yangtools.yang.common.RpcError)

Example 59 with Message

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message in project openflowplugin by opendaylight.

the class DeviceContextImpl method processPacketInMessage.

@Override
public void processPacketInMessage(final PacketInMessage packetInMessage) {
    if (isMasterOfDevice()) {
        final PacketReceived packetReceived = packetInTranslator.translate(packetInMessage, getDeviceInfo(), null);
        handlePacketInMessage(packetReceived, packetInMessage.getImplementedInterface(), packetReceived.getMatch());
    } else {
        LOG.debug("Controller is not owner of the device {}, skipping packet_in message", deviceInfo.getLOGValue());
    }
}
Also used : PacketReceived(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived)

Example 60 with Message

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message in project openflowplugin by opendaylight.

the class DeviceContextImpl method processExperimenterMessage.

@Override
public void processExperimenterMessage(final ExperimenterMessage notification) {
    if (isMasterOfDevice()) {
        // lookup converter
        final ExperimenterDataOfChoice vendorData = notification.getExperimenterDataOfChoice();
        final MessageTypeKey<? extends ExperimenterDataOfChoice> key = new MessageTypeKey<>(getDeviceInfo().getVersion(), (Class<? extends ExperimenterDataOfChoice>) vendorData.getImplementedInterface());
        final ConvertorMessageFromOFJava<ExperimenterDataOfChoice, MessagePath> messageConverter = extensionConverterProvider.getMessageConverter(key);
        if (messageConverter == null) {
            LOG.warn("custom converter for {}[OF:{}] not found", notification.getExperimenterDataOfChoice().getImplementedInterface(), getDeviceInfo().getVersion());
            return;
        }
        // build notification
        final ExperimenterMessageOfChoice messageOfChoice;
        try {
            messageOfChoice = messageConverter.convert(vendorData, MessagePath.MESSAGE_NOTIFICATION);
            final ExperimenterMessageFromDevBuilder experimenterMessageFromDevBld = new ExperimenterMessageFromDevBuilder().setNode(new NodeRef(getDeviceInfo().getNodeInstanceIdentifier())).setExperimenterMessageOfChoice(messageOfChoice);
            // publish
            notificationPublishService.offerNotification(experimenterMessageFromDevBld.build());
        } catch (final ConversionException e) {
            LOG.error("Conversion of experimenter notification failed", e);
        }
    } else {
        LOG.debug("Controller is not owner of the device {}, skipping experimenter message", deviceInfo.getLOGValue());
    }
}
Also used : ConversionException(org.opendaylight.openflowplugin.extension.api.exception.ConversionException) MessagePath(org.opendaylight.openflowplugin.extension.api.path.MessagePath) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) ExperimenterMessageFromDevBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.ExperimenterMessageFromDevBuilder) ExperimenterMessageOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.experimenter.core.message.ExperimenterMessageOfChoice) ExperimenterDataOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice) MessageTypeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey)

Aggregations

Test (org.junit.Test)202 ByteBuf (io.netty.buffer.ByteBuf)184 ArrayList (java.util.ArrayList)109 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)53 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)45 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)44 BigInteger (java.math.BigInteger)37 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)26 MultipartRequestInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput)25 MultipartRequestInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder)25 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)22 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)21 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update)21 List (java.util.List)18 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder)18 PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)17 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)17 Message (org.eclipse.bpmn2.Message)16 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)15 Message (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message)15