Esempio n. 1
0
 public void Update(DhcpClient dhcpClient)
 {
     HostName   = dhcpClient.HostName;
     IpAddress  = dhcpClient.IpAddress;
     MacAddress = dhcpClient.MacAddress;
     LeaseTime  = dhcpClient.LeaseTime;
 }
Esempio n. 2
0
        private static IEnumerable <DhcpClient> GetLanDhcpClientsFromContent(string pageSource, string startString, int rowArrayLength)
        {
            string contentCsv = ExtractCsvFromContent(pageSource, startString);

            contentCsv = CleanUpContent(contentCsv);

            IEnumerable <string[]> rowValues = GetArrayFromCsvContent(contentCsv, rowArrayLength);

            var clients = new List <DhcpClient>();

            foreach (string[] rowValue in rowValues)
            {
                var i      = 0;
                var client = new DhcpClient
                {
                    HostName   = rowValue[i++],
                    IpAddress  = rowValue[i++],
                    MacAddress = rowValue[i++],
                    LeaseTime  = GetTimeSpan(rowValue[i])
                };
                clients.Add(client);
            }

            return(clients);
        }
        static int Main()
        {
            StaticConfiguration.Initialize();
            StaticConfiguration.Start();

            FakeDhcpServer fakeDhcpServer = new FakeDhcpServer();
            DebugAdapter   adapter        = new DebugAdapter(fakeDhcpServer);

            Console.WriteLine("Created Debug Adapter {0}",
                              adapter.HardwareAddress);
            Core.Instance().RegisterAdapter(adapter, 64);

            DhcpClient dc = new DhcpClient(adapter);

            dc.Start();

            while (fakeDhcpServer.State == FakeDhcpServer.ServerState.Running)
            {
                Thread.Sleep(TimeSpan.FromSeconds(1));
            }
            dc.Stop();

            Console.WriteLine("Removing Adapter.");
            Core.Instance().DeregisterAdapter(adapter);

            StaticConfiguration.Stop();

            if (fakeDhcpServer.State == FakeDhcpServer.ServerState.Failed)
            {
                return(1);
            }
            return(0);
        }