Example #1
0
        /// <summary>Someone told us we didn't have a mapping... let's fix that.</summary>
        protected override bool MappingMissing(MemBlock ip)
        {
            if (!base.MappingMissing(ip))
            {
                return(false);
            }

            // Easiest approach is to simply update the mapping...
            DhcpServer dhcp_server = GetDhcpServer();

            try {
                dhcp_server.RequestLease(ip, true, AppNode.Node.Address.ToString(),
                                         _ipop_config.AddressData.Hostname);
            } catch (Exception e) {
                ProtocolLog.WriteIf(IpopLog.DhcpLog, e.Message);
            }

            return(true);
        }
Example #2
0
        /// <summary> Occassionally nodes will get a true return from a allocation
        /// attempt, in order to prevent this, we reissue all dhcp requests after
        /// getting "connected" to the overlay.</summary>
        protected void StateChangeHandler(Node n, Node.ConnectionState state)
        {
            List <MemBlock> ips = null;

            lock (_sync) {
                if (state == Node.ConnectionState.Connected)
                {
                    if (_connected)
                    {
                        return;
                    }
                    AppNode.Node.StateChangeEvent -= StateChangeHandler;
                    _connected = true;
                }
                else
                {
                    return;
                }

                ips = new List <MemBlock>(_ip_to_ether.Keys.Count);
                foreach (MemBlock ip in _ip_to_ether.Keys)
                {
                    ips.Add(ip);
                }
            }

            WaitCallback callback = delegate(object o) {
                // Get a new Dhcp server so we get new state!
                DhcpServer dhcp_server = GetDhcpServer();
                foreach (MemBlock ip in ips)
                {
                    try {
                        dhcp_server.RequestLease(ip, true, AppNode.Node.Address.ToString(),
                                                 _ipop_config.AddressData.Hostname);
                    } catch (Exception e) {
                        ProtocolLog.WriteIf(IpopLog.DhcpLog, e.Message);
                    }
                }
            };

            ThreadPool.QueueUserWorkItem(callback, null);
        }