Esempio n. 1
0
        /// <summary>
        /// The constructor which reads config setting and calls the constructor for the sockets and three servers.
        /// </summary>
        public ReflectorMgr()
        {
            string setting;

            if ( (setting = ConfigurationManager.AppSettings[AppConfig.JoinPort]) != null )
            {
                registrarServerPort = int.Parse(setting);
            }

            if ( (setting = ConfigurationManager.AppSettings[AppConfig.UnicastPort] ) != null )
            {
                reflectorUnicastRTPListenPort = int.Parse(setting);
            }

            TimeSpan timeoutPeriod = TimeSpan.Zero;
            if ( (setting = ConfigurationManager.AppSettings[AppConfig.TimeOutMinutes] ) != null )
            {
                // Minutes
                timeoutPeriod = new TimeSpan(0, int.Parse(setting), 0);
            }

            if ((setting = ConfigurationManager.AppSettings[AppConfig.MultipleInterfaceSupport] ) != null)
            {
                multipleInterfaceSupport = bool.Parse(setting);
            }

            if ((setting = ConfigurationManager.AppSettings[AppConfig.IPv4Support] ) != null)
            {
                if(bool.Parse(setting))
                {
                    enabledTrafficTypes |= TrafficType.IPv4;
                }
            }

            if ((setting = ConfigurationManager.AppSettings[AppConfig.IPv6Support] ) != null)
            {
                if(bool.Parse(setting))
                {
                    if (Socket.OSSupportsIPv6)
                    {
                        enabledTrafficTypes |= TrafficType.IPv6;
                    }
                    else
                    {
                        eventLog.WriteEntry("IPv6 not enabled in OS.  Ignoring IPv6 from app.config.",
                            EventLogEntryType.Warning, ReflectorEventLog.ID.Error);
                    }
                }
            }

            // If the user has set both IPv6 support and IPv4 support to false, we go to default
            // config: IPv4Support only.
            if (enabledTrafficTypes < TrafficType.IPv4)
            {
                enabledTrafficTypes = TrafficType.IPv4;
            }

            if ((setting = ConfigurationManager.AppSettings[AppConfig.MCLoopbackOff] ) != null)
            {
                mcLoopbackOff = bool.Parse(setting);
            }

            if ((setting = ConfigurationManager.AppSettings[AppConfig.MulticastInterfaceRouteIndex] ) != null)
            {
                // Route print produces a hexadecimal number
                mcInterfaceRouteIndex = Convert.ToInt32(setting, 16);
            }

            if ((enabledTrafficTypes & TrafficType.IPv4) == TrafficType.IPv4)
            {

                if ( ((setting = ConfigurationManager.AppSettings[AppConfig.MulticastInterfaceIP] ) != null)
                    && multipleInterfaceSupport)
                {
                    multicastInterfaceIP = IPAddress.Parse(setting);
                }
                else
                {
                    //Workaround: Pass a generic IPv4 multicast IP.
                    multicastInterfaceIP = Utility.GetLocalRoutingInterface(IPAddress.Parse("233.4.5.6"));
                }

                if (((setting = ConfigurationManager.AppSettings[AppConfig.UnicastInterfaceIP] ) != null)
                    && multipleInterfaceSupport)
                {
                    unicastInterfaceIP = IPAddress.Parse(setting);
                }
                else
                {
                    // The interface which is routed toward the Root name servers
                    unicastInterfaceIP = Utility.GetLocalRoutingInterface(IPAddress.Parse("198.41.0.4"));
                }
            }

            if ((enabledTrafficTypes & TrafficType.IPv6) == TrafficType.IPv6)
            {

                if ( ((setting = ConfigurationManager.AppSettings[AppConfig.IPv6MulticastInterfaceIP] ) != null)
                    && multipleInterfaceSupport)
                {
                    IPv6multicastInterfaceIP = IPAddress.Parse(setting);
                }
                else
                {
                    //Workaround: Pass a generic IPv6 multicast IP.
                    IPv6multicastInterfaceIP = Utility.GetLocalRoutingInterface(IPAddress.Parse("ff1e::1"));
                }

                if (((setting = ConfigurationManager.AppSettings[AppConfig.IPv6UnicastInterfaceIP] ) != null)
                    && multipleInterfaceSupport)
                {
                    IPv6unicastInterfaceIP = IPAddress.Parse(setting);
                }
                else
                {
                    // The interface which is routed toward 6bone.net
                    IPv6unicastInterfaceIP = Utility.GetLocalRoutingInterface(IPAddress.Parse("2001:5c0:0:2::24"));
                }
            }

            try
            {
                sockets = new ReflectorSockets(enabledTrafficTypes);
            }
            catch(Exception e)
            {
                eventLog.WriteEntry(e.ToString(), EventLogEntryType.Error, (int)ReflectorEventLog.ID.Error);
                throw;
            }

            regServer = new RegistrarServer(enabledTrafficTypes, timeoutPeriod);
            UMforwarder = new UCtoUCMC(enabledTrafficTypes);
            MUforwarder = new MCtoUC(enabledTrafficTypes);
        }
Esempio n. 2
0
        /// <summary>
        /// The constructor which reads config setting and calls the constructor for the sockets and three servers.
        /// </summary>
        public ReflectorMgr()
        {
            string setting;

            if ((setting = ConfigurationManager.AppSettings[AppConfig.JoinPort]) != null)
            {
                registrarServerPort = int.Parse(setting);
            }

            if ((setting = ConfigurationManager.AppSettings[AppConfig.UnicastPort]) != null)
            {
                reflectorUnicastRTPListenPort = int.Parse(setting);
            }

            TimeSpan timeoutPeriod = TimeSpan.Zero;

            if ((setting = ConfigurationManager.AppSettings[AppConfig.TimeOutMinutes]) != null)
            {
                // Minutes
                timeoutPeriod = new TimeSpan(0, int.Parse(setting), 0);
            }

            if ((setting = ConfigurationManager.AppSettings[AppConfig.MultipleInterfaceSupport]) != null)
            {
                multipleInterfaceSupport = bool.Parse(setting);
            }

            if ((setting = ConfigurationManager.AppSettings[AppConfig.IPv4Support]) != null)
            {
                if (bool.Parse(setting))
                {
                    enabledTrafficTypes |= TrafficType.IPv4;
                }
            }

            if ((setting = ConfigurationManager.AppSettings[AppConfig.IPv6Support]) != null)
            {
                if (bool.Parse(setting))
                {
                    if (Socket.OSSupportsIPv6)
                    {
                        enabledTrafficTypes |= TrafficType.IPv6;
                    }
                    else
                    {
                        eventLog.WriteEntry("IPv6 not enabled in OS.  Ignoring IPv6 from app.config.",
                                            EventLogEntryType.Warning, ReflectorEventLog.ID.Error);
                    }
                }
            }

            // If the user has set both IPv6 support and IPv4 support to false, we go to default
            // config: IPv4Support only.
            if (enabledTrafficTypes < TrafficType.IPv4)
            {
                enabledTrafficTypes = TrafficType.IPv4;
            }

            if ((setting = ConfigurationManager.AppSettings[AppConfig.MCLoopbackOff]) != null)
            {
                mcLoopbackOff = bool.Parse(setting);
            }

            if ((setting = ConfigurationManager.AppSettings[AppConfig.MulticastInterfaceRouteIndex]) != null)
            {
                // Route print produces a hexadecimal number
                mcInterfaceRouteIndex = Convert.ToInt32(setting, 16);
            }

            if ((enabledTrafficTypes & TrafficType.IPv4) == TrafficType.IPv4)
            {
                if (((setting = ConfigurationManager.AppSettings[AppConfig.MulticastInterfaceIP]) != null) &&
                    multipleInterfaceSupport)
                {
                    multicastInterfaceIP = IPAddress.Parse(setting);
                }
                else
                {
                    //Workaround: Pass a generic IPv4 multicast IP.
                    multicastInterfaceIP = Utility.GetLocalRoutingInterface(IPAddress.Parse("233.4.5.6"));
                }


                if (((setting = ConfigurationManager.AppSettings[AppConfig.UnicastInterfaceIP]) != null) &&
                    multipleInterfaceSupport)
                {
                    unicastInterfaceIP = IPAddress.Parse(setting);
                }
                else
                {
                    // The interface which is routed toward the Root name servers
                    unicastInterfaceIP = Utility.GetLocalRoutingInterface(IPAddress.Parse("198.41.0.4"));
                }
            }

            if ((enabledTrafficTypes & TrafficType.IPv6) == TrafficType.IPv6)
            {
                if (((setting = ConfigurationManager.AppSettings[AppConfig.IPv6MulticastInterfaceIP]) != null) &&
                    multipleInterfaceSupport)
                {
                    IPv6multicastInterfaceIP = IPAddress.Parse(setting);
                }
                else
                {
                    //Workaround: Pass a generic IPv6 multicast IP.
                    IPv6multicastInterfaceIP = Utility.GetLocalRoutingInterface(IPAddress.Parse("ff1e::1"));
                }


                if (((setting = ConfigurationManager.AppSettings[AppConfig.IPv6UnicastInterfaceIP]) != null) &&
                    multipleInterfaceSupport)
                {
                    IPv6unicastInterfaceIP = IPAddress.Parse(setting);
                }
                else
                {
                    // The interface which is routed toward 6bone.net
                    IPv6unicastInterfaceIP = Utility.GetLocalRoutingInterface(IPAddress.Parse("2001:5c0:0:2::24"));
                }
            }

            try
            {
                sockets = new ReflectorSockets(enabledTrafficTypes);
            }
            catch (Exception e)
            {
                eventLog.WriteEntry(e.ToString(), EventLogEntryType.Error, (int)ReflectorEventLog.ID.Error);
                throw;
            }

            regServer   = new RegistrarServer(enabledTrafficTypes, timeoutPeriod);
            UMforwarder = new UCtoUCMC(enabledTrafficTypes);
            MUforwarder = new MCtoUC(enabledTrafficTypes);
        }