The DhtDhcpLeaseController provides mechanisms to acquire IP Addresses in the Dht. This is responsible for IP Address allocation, hostname reservation, and multicast subscribing, which is done in GetLease.
상속: Ipop.DhcpServer
예제 #1
0
        /// <summary>We need to get the DHCPConfig as soon as possible so that we
        /// can allocate static addresses, this method helps us do that.</summary>
        protected override void GetDhcpConfig()
        {
            if (Interlocked.Exchange(ref _lock, 1) == 1)
            {
                return;
            }

            WaitCallback wcb = delegate(object o) {
                bool       success     = false;
                DHCPConfig dhcp_config = null;
                try {
                    dhcp_config = DhtDhcpServer.GetDhcpConfig(AppNode.Dht, _ipop_config.IpopNamespace);
                    success     = true;
                } catch (Exception e) {
                    ProtocolLog.WriteIf(IpopLog.DhcpLog, e.ToString());
                }

                if (success)
                {
                    lock (_sync) {
                        _dhcp_config = dhcp_config;
                        _dhcp_server = new DhtDhcpServer(AppNode.Dht, _dhcp_config, _ipop_config.EnableMulticast);
                    }
                }
                base.GetDhcpConfig();

                Interlocked.Exchange(ref _lock, 0);
            };

            ThreadPool.QueueUserWorkItem(wcb);
        }
예제 #2
0
        /// <summary>We need to get the DHCPConfig as soon as possible so that we
        /// can allocate static addresses, this method helps us do that.</summary>
        protected override void GetDhcpConfig()
        {
            if(Interlocked.Exchange(ref _lock, 1) == 1) {
            return;
              }

              WaitCallback wcb = delegate(object o) {
            bool success = false;
            DHCPConfig dhcp_config = null;
            try {
              dhcp_config = DhtDhcpServer.GetDhcpConfig(AppNode.Dht, _ipop_config.IpopNamespace);
              success = true;
            } catch(Exception e) {
              ProtocolLog.WriteIf(IpopLog.DhcpLog, e.ToString());
            }

            if(success) {
              lock(_sync) {
            _dhcp_config = dhcp_config;
            _dhcp_server = new DhtDhcpServer(AppNode.Dht, _dhcp_config, _ipop_config.EnableMulticast);
              }
            }
            base.GetDhcpConfig();

            Interlocked.Exchange(ref _lock, 0);
              };

              ThreadPool.QueueUserWorkItem(wcb);
        }