private bool AreAnyMapiNicsUp(AmNetworkMonitor.Node node)
        {
            int num = 0;

            foreach (AmNetworkMonitor.Nic nic in node.MapiNics)
            {
                num++;
                AmNetInterfaceState nicState = this.GetNicState(nic.Name);
                switch (nicState)
                {
                case AmNetInterfaceState.Unavailable:
                case AmNetInterfaceState.Failed:
                case AmNetInterfaceState.Unreachable:
                    AmNetworkMonitor.Tracer.TraceError <string, AmNetInterfaceState>(0L, "Nic '{0}' is {1}.", nic.Name, nicState);
                    break;

                case AmNetInterfaceState.Up:
                    return(true);

                default:
                    AmNetworkMonitor.Tracer.TraceError <string, AmNetInterfaceState>(0L, "Nic '{0}' is {1}.", nic.Name, nicState);
                    return(true);
                }
            }
            AmNetworkMonitor.Tracer.TraceError <AmServerName, int>(0L, "Node {0} has {1} MAPI nics. None appear usable.", node.Name, num);
            return(false);
        }
        public List <AmServerName> GetServersReportedAsPubliclyUp()
        {
            List <AmServerName> list = new List <AmServerName>();
            Dictionary <AmServerName, AmNetworkMonitor.Node> nodeTable = this.m_nodeTable;

            if (nodeTable != null)
            {
                foreach (KeyValuePair <AmServerName, AmNetworkMonitor.Node> keyValuePair in nodeTable)
                {
                    AmNetworkMonitor.Node value = keyValuePair.Value;
                    if (this.IsNodePubliclyUp(value))
                    {
                        list.Add(value.Name);
                    }
                }
            }
            return(list);
        }
        private bool IsNodePubliclyUp(AmNetworkMonitor.Node node)
        {
            IAmCluster cluster = this.GetCluster();

            if (cluster == null)
            {
                AmNetworkMonitor.Tracer.TraceError <AmServerName>(0L, "If cluster object is not valid, then assume node {0} is up", node.Name);
                return(true);
            }
            Exception   ex;
            AmNodeState nodeState = cluster.GetNodeState(node.Name, out ex);

            if (ex != null)
            {
                return(false);
            }
            if (!AmClusterNode.IsNodeUp(nodeState))
            {
                return(false);
            }
            AmClusterNodeNetworkStatus amClusterNodeNetworkStatus = AmClusterNodeStatusAccessor.Read(cluster, node.Name, out ex);

            return(amClusterNodeNetworkStatus == null || amClusterNodeNetworkStatus.HasADAccess);
        }
        public void RefreshMapiNetwork()
        {
            Exception ex = null;

            try
            {
                Dictionary <AmServerName, AmNetworkMonitor.Node> dictionary  = new Dictionary <AmServerName, AmNetworkMonitor.Node>();
                Dictionary <string, AmNetworkMonitor.Nic>        dictionary2 = new Dictionary <string, AmNetworkMonitor.Nic>();
                using (IAmCluster amCluster = ClusterFactory.Instance.Open())
                {
                    lock (this)
                    {
                        ExTraceGlobals.AmNetworkMonitorTracer.TraceDebug((long)this.GetHashCode(), "RefreshMapiNetwork running");
                        foreach (IAmClusterNode amClusterNode in amCluster.EnumerateNodes())
                        {
                            using (amClusterNode)
                            {
                                AmNetworkMonitor.Node node = new AmNetworkMonitor.Node(amClusterNode.Name);
                                dictionary.Add(node.Name, node);
                                IPAddress[] dnsAddresses = NetworkUtil.GetDnsAddresses(amClusterNode.Name.Fqdn, ref ex);
                                foreach (AmClusterNetInterface amClusterNetInterface in amClusterNode.EnumerateNetInterfaces())
                                {
                                    using (amClusterNetInterface)
                                    {
                                        bool      flag2     = false;
                                        IPAddress ipaddress = NetworkUtil.ConvertStringToIpAddress(amClusterNetInterface.GetAddress());
                                        if (ipaddress != null && NetworkUtil.IsAddressPresent(dnsAddresses, ipaddress))
                                        {
                                            flag2 = true;
                                            AmNetworkMonitor.Tracer.TraceDebug <string, IPAddress>((long)this.GetHashCode(), "NIC '{0}' on DNS at {1}", amClusterNetInterface.Name, ipaddress);
                                        }
                                        if (!flag2)
                                        {
                                            string[] ipv6Addresses = amClusterNetInterface.GetIPv6Addresses();
                                            if (ipv6Addresses != null && ipv6Addresses.Length > 0)
                                            {
                                                foreach (string text in ipv6Addresses)
                                                {
                                                    ipaddress = NetworkUtil.ConvertStringToIpAddress(text);
                                                    if (ipaddress != null && NetworkUtil.IsAddressPresent(dnsAddresses, ipaddress))
                                                    {
                                                        flag2 = true;
                                                        AmNetworkMonitor.Tracer.TraceDebug <string, string>((long)this.GetHashCode(), "NIC '{0}' on DNS at {1}", amClusterNetInterface.Name, text);
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                        if (flag2)
                                        {
                                            AmNetworkMonitor.Nic nic = new AmNetworkMonitor.Nic(amClusterNetInterface.Name, node);
                                            node.MapiNics.Add(nic);
                                            dictionary2.Add(nic.Name, nic);
                                        }
                                    }
                                }
                            }
                        }
                        this.m_nodeTable = dictionary;
                        this.m_nicTable  = dictionary2;
                    }
                }
            }
            catch (ClusterException ex2)
            {
                ex = ex2;
            }
            finally
            {
                this.m_firstRefreshCompleted.Set();
                this.m_firstRefreshCompleted.Close();
            }
            if (ex != null)
            {
                AmNetworkMonitor.Tracer.TraceError <Exception>(0L, "RefreshMapiNetwork fails:{0}", ex);
            }
        }
 public Nic(string name, AmNetworkMonitor.Node node)
 {
     this.Name = name;
     this.Node = node;
 }