예제 #1
0
        public static sNetworkCard Load(string iface)
        {
            sNetworkCard ret = null;

            foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
            {
                if (ni.Name == iface)
                {
                    ret = new sNetworkCard(ni);
                }
                else
                {
                    if (ni.GetIPProperties().GetIPv4Properties().IsDhcpEnabled&& ni.OperationalStatus == OperationalStatus.Up)
                    {
                        foreach (UnicastIPAddressInformation uipa in ni.GetIPProperties().UnicastAddresses)
                        {
                            if (uipa.Address.AddressFamily == global::System.Net.Sockets.AddressFamily.InterNetwork)
                            {
                                if (iface == uipa.Address.ToString())
                                {
                                    ret = new sNetworkCard(ni);
                                    break;
                                }
                            }
                        }
                    }
                }
                if (ret != null)
                {
                    break;
                }
            }
            return(ret);
        }
예제 #2
0
 public static sNetworkCard Load(string iface)
 {
     sNetworkCard ret = null;
     foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
     {
         if (ni.Name == iface)
             ret = new sNetworkCard(ni);
         else
         {
             if (ni.GetIPProperties().GetIPv4Properties().IsDhcpEnabled && ni.OperationalStatus == OperationalStatus.Up)
             {
                 foreach (UnicastIPAddressInformation uipa in ni.GetIPProperties().UnicastAddresses)
                 {
                     if (uipa.Address.AddressFamily == global::System.Net.Sockets.AddressFamily.InterNetwork)
                     {
                         if (iface == uipa.Address.ToString())
                         {
                             ret = new sNetworkCard(ni);
                             break;
                         }
                     }
                 }
             }
         }
         if (ret != null)
             break;
     }
     return ret;
 }