예제 #1
0
        public static void WriteInterfaceLine([Claims] InterfaceInfo ifInfo, string !ifName)
        {
            bool found = false;

            delete ifInfo.driverName;
            delete ifInfo.driverVersion;

            InterfaceIPInfo[] in ExHeap ipConfigs = ifInfo.ipConfigs;

            if (ipConfigs != null)
            {
                for (int i = 0; i < ipConfigs.Length; i++)
                {
                    InterfaceIPInfo ipc  = ipConfigs[i];
                    IPv4            ipv4 = new IPv4(ipc.address);

                    Console.WriteLine("TESTUTIL:IPAddress: {0,-14}", ipv4);
                    DebugStub.WriteLine("TESTUTIL:IPAddress:{0}:", __arglist(ipv4.ToString()));
                    found |= true;
                }
                delete ipConfigs;
            }

            if (found == false)
            {
                DebugStub.WriteLine("TESTUTIL:IPAddress: Not available.");
            }
        }
예제 #2
0
파일: Network.cs 프로젝트: QCX51/Slave
        internal static bool GetIPHostEntry(ref string Hostname)
        {
            IPHostEntry IPHE;

            try { IPHE = Dns.GetHostEntry(Hostname); }
            catch (System.Exception ex) { Hostname = ex.Message; return(false); }
            foreach (IPAddress IPv4 in IPHE.AddressList)
            {
                if (IPv4.AddressFamily == AddressFamily.InterNetwork)
                {
                    Hostname = IPv4.ToString(); return(true);
                }
            }
            return(false);
        }
예제 #3
0
        internal string ToSummary()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("FQDN:");
            sb.AppendLine(GetFQDN());
            //TODO: Need Value Converter to convert IP Address from string and back
            sb.Append("IPv4:");
            sb.AppendLine(IPv4?.ToString());
            sb.Append("IPv6:");
            sb.AppendLine(IPv6?.ToString());
            sb.Append("OSInfo:");
            sb.AppendLine(OS?.ToString());

            return(sb.ToString());
        }
예제 #4
0
        internal override void EnterEvent()
        {
            // Yay! We got DHCP configuration information
            DateTime now = DateTime.Now;

            // Set up renewal timer
            DhcpDWordOption renewalOption =
                hostOptions[DhcpRenewalTime.OptionCode] as DhcpDWordOption;

            uint renewalSeconds = 3600;

            if (renewalOption != null)
            {
                renewalSeconds = renewalOption.Value;
            }
            client.SetRenewalTimeout(now + TimeSpan.FromSeconds(renewalSeconds));

            // Set up rebinding timer
            DhcpDWordOption rebindOption =
                hostOptions[DhcpRebindingTime.OptionCode] as DhcpDWordOption;
            uint rebindSeconds = renewalSeconds + 60;

            if (rebindOption != null)
            {
                rebindSeconds = Math.Max(rebindOption.Value,
                                         renewalSeconds + 1);
            }
            client.SetRebindTimeout(now + TimeSpan.FromSeconds(rebindSeconds));

            // Add host address as a dhcp option and then get client
            // to install settings.
            hostOptions[DhcpRequestedIPAddress.OptionCode] =
                DhcpRequestedIPAddress.Create(hostAddress);

            if (client.InstallDhcpOptions(hostOptions) == false)
            {
                client.ChangeState(new DhcpClientStateInitialize(client));
            }
            DebugStub.WriteLine("\nDHCP client acquired lease of {0} for {1} seconds.",
                                __arglist(hostAddress.ToString(), rebindSeconds));
        }
예제 #5
0
 public override string ToString()
 {
     return(m_addr.ToString());
 }