Esempio n. 1
0
        static void displayResultsNoArgs()
        {
            NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
            Console.WriteLine("Windows IP Configuration" + "\r\n\n");
            foreach (NetworkInterface adapter in nics)
            {
                NetworkInterfaceType type = adapter.NetworkInterfaceType;
                if (type.ToString().Equals("Loopback") || type.ToString().Equals("Tunnel"))
                {
                    continue;
                }
                IPInterfaceProperties properties = adapter.GetIPProperties();
                Console.WriteLine("{0} adapter {1}:\r\n", type, adapter.Name);

                if (adapter.OperationalStatus == OperationalStatus.Up)
                {
                    String[] IPSet = IPAddresses(adapter, properties);
                    Console.WriteLine("Connection-specific DNS Suffix  . : {0}", properties.DnsSuffix);
                    Console.WriteLine("Link-local IPv6 Address . . . . . : {0}", IPSet[0]);
                    Console.WriteLine("IPv4 Address . . . . . . . . . .  : {0}", IPSet[1]);
                    Console.WriteLine("Subnet Mask . . . . . . . . . . . : {0}", IPSet[2]);
                    Console.WriteLine("Default Gateway . . . . . . . . . : {0}", DefaultGatewayAddress(properties) + "\r\n");
                }
                else
                {
                    string status = "Media disconnected";
                    Console.WriteLine("   Media State . . . . . . . . . . . : {0}", status);
                }
            }
        }
Esempio n. 2
0
 public Connection(string name, NetworkInterfaceType type, bool connection)
 {
     this.ConnectionType       = type;
     this.HasConnection        = connection;
     this.IsEthernetConnection = (type.ToString().Contains("Ethernet"));
     this.NetworkName          = name;
 }
 private static string Translate(NetworkInterfaceType key)
 {
     switch (key) {
         case NetworkInterfaceType.Ethernet:
             return "eth";
         default:
             return key.ToString();
     }
 }
Esempio n. 4
0
        private static string Translate(NetworkInterfaceType key)
        {
            switch (key)
            {
            case NetworkInterfaceType.Ethernet:
                return("eth");

            default:
                return(key.ToString());
            }
        }
Esempio n. 5
0
        static void displayAllConfigInfo()
        {
            NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
            Console.WriteLine("Windows IP Configuration" + "\r\n");
            UserInfo();

            foreach (NetworkInterface adapter in nics)
            {
                NetworkInterfaceType type = adapter.NetworkInterfaceType;
                if (type.ToString().Equals("Loopback"))
                {
                    continue;
                }
                IPInterfaceProperties properties = adapter.GetIPProperties();
                Boolean DHCPEnabled;
                Boolean AutoConfig;
                if (!adapter.Supports(NetworkInterfaceComponent.IPv4))
                {
                    DHCPEnabled = false;
                    if (type.ToString().Equals("Tunnel"))
                    {
                        AutoConfig = true;
                    }
                    else
                    {
                        AutoConfig = false;
                    }
                }
                else
                {
                    DHCPEnabled = properties.GetIPv4Properties().IsDhcpEnabled;
                    AutoConfig  = properties.GetIPv4Properties().IsAutomaticPrivateAddressingEnabled;
                }
                Console.WriteLine("{0} adapter {1}:\r\n", type, adapter.Name);

                if (adapter.OperationalStatus != OperationalStatus.Up)
                {
                    Console.WriteLine("Media State . . . . . . . . . . . : Media Disconnected");
                }
                Console.WriteLine("Connection-specific DNS Suffix  . : {0}", properties.DnsSuffix);
                Console.WriteLine("Description . . . . . . . . . . . : {0}", adapter.Description);
                Console.WriteLine("Physical Address. . . . . . . .  : {0}", physicalAddress(adapter));
                Console.WriteLine("DHCP Enabled . . . . . . . . . .  : {0}", DHCPEnabled);
                Console.WriteLine("Autoconfiguration Enabled . . . . : {0}", AutoConfig);

                if (adapter.OperationalStatus != OperationalStatus.Up)
                {
                    Console.WriteLine("");
                    continue;
                }
                String[] IPSet = IPAddresses(adapter, properties);
                Console.WriteLine("Link-local IPv6 Address. . . . .  : {0}<Preferred>", IPSet[0]);
                Console.WriteLine("IPv4 Address. . . . . . . . . . . : {0}<Preferred>", IPSet[1]);
                Console.WriteLine("Subnet Mask . . . . . . . . . . . : {0}", IPSet[2]);
                Console.WriteLine("Lease Obtained . . . . . . . . .  : {0} placeholder");
                Console.WriteLine("Default Gateway . . . . . . . . . : {0}", DefaultGatewayAddress(properties));
                Console.WriteLine("DHCP Server . . . . . . . . . . . : {0}", IPSet[3]);
                Console.WriteLine("DHCPv6 IAID . . . . . . . . . . . : {0}");
                Console.WriteLine("DHCPv6 Client DUID . . . . . . .  : {0}" + "\r\n");
                Console.WriteLine("DNS Servers  . . . . . . . . . .  : {0}", IPSet[4]);
                Console.WriteLine("NetBIOS over Tcpip . . . . . . .  : {0}" + "\r\n");
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public String GetNetworkCardType()
 {
     return(networkCardType.ToString());
 }