예제 #1
0
        public bool ConfigureTransport(ref DomainParticipantQos qos)
        {
            /*
             * If transportConfig.kind is not set, then we want to use the value
             * provided by the Participant Qos, so first we read it from there and
             * update the value of transportConfig.kind with whatever was already set.
             */
            if (TransportConfig.Kind == Transport.None)
            {
                TransportConfig = qos.TransportBuiltin.Mask switch
                {
                    TransportBuiltinMask.Udpv4 => new TransportConfig(
                        Transport.Udpv4,
                        "UDPv4",
                        "dds.transport.UDPv4.builtin"),
                    TransportBuiltinMask.Udpv6 => new TransportConfig(
                        Transport.Udpv6,
                        "UDPv6",
                        "dds.transport.UDPv6.builtin"),
                    TransportBuiltinMask.Shmem => new TransportConfig(
                        Transport.Shmem,
                        "SHMEM",
                        "dds.transport.shmem.builtin"),
                    TransportBuiltinMask.Shmem | TransportBuiltinMask.Udpv4 => new TransportConfig(
                        Transport.Udpv4Shmem,
                        "UDPv4 & SHMEM",
                        "dds.transport.UDPv4.builtin"),
                    TransportBuiltinMask.Udpv6 | TransportBuiltinMask.Udpv4 => new TransportConfig(
                        Transport.Udpv4Udpv6,
                        "UDPv4 & UDPv6",
                        "dds.transport.UDPv4.builtin"),
                    TransportBuiltinMask.Udpv6 | TransportBuiltinMask.Shmem => new TransportConfig(
                        Transport.Udpv6Shmem,
                        "UDPv6 & SHMEM",
                        "dds.transport.UDPv6.builtin"),
                    TransportBuiltinMask.Udpv4 | TransportBuiltinMask.Udpv6 | TransportBuiltinMask.Shmem
                    => new TransportConfig(
                        Transport.Udpv4Udpv6Shmem,
                        "UDPv4 & UDPv6 & SHMEM",
                        "dds.transport.UDPv4.builtin"),

                    /*
                     * This would mean that the mask is either empty or a
                     * different value that we do not support yet. So we keep
                     * the value as "TRANSPORT_NOT_SET"
                     */
                    _ => null
                };
                TransportConfig.TakenFromQoS = true;
            }

            switch (TransportConfig.Kind)
            {
            case Transport.Udpv4:
                qos = qos.WithTransportBuiltin(policy =>
                                               policy.Mask = TransportBuiltinMask.Udpv4);
                break;

            case Transport.Udpv6:
                qos = qos.WithTransportBuiltin(policy =>
                                               policy.Mask = TransportBuiltinMask.Udpv6);
                break;

            case Transport.Shmem:
                qos = qos.WithTransportBuiltin(policy =>
                                               policy.Mask = TransportBuiltinMask.Shmem);
                break;
            }

            /*
             * Once the configurations have been established, we can get the
             * MessageSizeMax for the Transport, which should be the minimum of
             * all the enabled transports
             */
            GetTransportMinimumMessageSizeMax(qos);

            switch (TransportConfig.Kind)
            {
            case Transport.Udpv4:
                break;

            case Transport.Udpv6:
                break;

            case Transport.Shmem:
                ConfigureShmemTransport(ref qos);
                break;

            case Transport.Tcpv4:
                qos = ConfigureTcpTransport(qos);
                if (qos == null)
                {
                    Console.Error.Write(ClassLoggingString + " Failed to configure TCP plugin");
                    return(false);
                }
                break;

            case Transport.Tlsv4:
                qos = ConfigureTcpTransport(qos);
                if (qos == null)
                {
                    Console.Error.Write(ClassLoggingString + " Failed to configure TCP - TLS plugin");
                    return(false);
                }
                break;

            case Transport.Dtlsv4:
                ConfigureDtlsTransport(ref qos);
                break;

            case Transport.Wanv4:
                if (!ConfigureWanTransport(ref qos))
                {
                    Console.Error.Write(ClassLoggingString + " Failed to configure WAN plugin");
                    return(false);
                }
                break;

            default:

                /*
                 * If shared memory is enabled we want to set up its
                 * specific configuration
                 */

                if (qos.TransportBuiltin.Mask == TransportBuiltinMask.Shmem)
                {
                    ConfigureShmemTransport(ref qos);
                }

                break;
            } // Switch

            if (TransportConfig.Kind != Transport.None &&
                TransportConfig.Kind != Transport.Shmem)
            {
                SetAllowInterfacesList(ref qos);
            }
            else
            {
                // We are not using the allow interface string, so we clear it
                parameters.AllowInterfaces = string.Empty;
            }

            SetTransportVerbosity(ref qos);

            return(true);
        }