Пример #1
0
 public NIC(ManagementObject nic)
 {
     this.nic = nic;
     if ((bool)nic["DHCPEnabled"])
     {
         this.backUp = null;
     }
     else
     {
         this.backUp = IPInformation.GetInstance(nic);
     }
     this.isChanged = false;
 }
Пример #2
0
    public static IPInformation GetInstance(string ip_subnet)
    {
        IPInformation instance;
        var           ipDatas = ip_subnet.Split(IPInformation.Slash);

        if (ipDatas.Length == 2)
        {
            instance = IPInformation.GetInstance(ipDatas[0], ipDatas[1]);
        }
        else
        {
            instance = null;
        }
        return(instance);
    }
Пример #3
0
    public static IPInformation GetInstance(byte[] ip, int cidr)
    {
        IPInformation instance;

        if (cidr >= 0 && cidr <= 32)
        {
            UInt32 mask   = 0xFFFFFFFF << (32 - cidr);
            byte[] subnet = new byte[4];
            for (int index = subnet.Length - 1; index >= 0; index--)
            {
                subnet[index] = (byte)(mask & 0xFF);
                mask        >>= 8;
            }
            instance = IPInformation.GetInstance(ip, subnet);
        }
        else
        {
            instance = null;
        }
        return(instance);
    }
Пример #4
0
    public static IPInformation GetInstance(byte[] ip, byte[] subnet)
    {
        IPInformation instance;

        if (ip == null || subnet == null)
        {
            instance = null;
        }
        if (ip.Length == 4 && subnet.Length == 4)
        {
            instance = new IPInformation(ip, subnet);
        }
        else if (ip.Length == 4 && subnet.Length == 1)
        {
            instance = IPInformation.GetInstance(ip, subnet[0]);
        }
        else
        {
            instance = null;
        }
        return(instance);
    }
Пример #5
0
 public bool SetStaticIPAddress(string ip_subnet)
 {
     return(this.SetStaticIPAddress(IPInformation.GetInstance(ip_subnet)));
 }
Пример #6
0
 public static IPInformation GetInstance(ManagementObject nic)
 {
     return(IPInformation.GetInstance(((string[])nic["IPAddress"])[0], ((string[])nic["IPSubnet"])[0]));
 }
Пример #7
0
 public static IPInformation GetInstance(string ip, int cidr)
 {
     return(IPInformation.GetInstance(IPInformation.ToIPBytes(ip), cidr));
 }
Пример #8
0
 public static IPInformation GetInstance(string ip, string subnet)
 {
     return(IPInformation.GetInstance(IPInformation.ToIPBytes(ip), IPInformation.ToIPBytes(subnet)));
 }