Beispiel #1
0
        /// <summary>拒绝</summary>
        /// <param name="dhcp"></param>
        /// <param name="state"></param>
        protected virtual void OnNak(DhcpEntity dhcp, Object state)
        {
            WriteLog("被拒绝 {0} 来自 {1}", Address, state);

            // 查找拒绝原因
            var opt = dhcp.Get(DhcpOptions.Message);

            if (opt != null)
            {
                WriteLog("拒绝原因:{0}", opt.ToStr());
            }
        }
Beispiel #2
0
        /// <summary>确认</summary>
        /// <param name="dhcp"></param>
        /// <param name="state"></param>
        protected virtual void OnAck(DhcpEntity dhcp, Object state)
        {
            WriteLog("已确认地址 {0} 来自 {1}", Address, state);

            // 查找租约时间
            var opt = dhcp.Get(DhcpOptions.IPLeaseTime);

            if (opt != null)
            {
                var buf = opt.Data.ReadBytes();
                buf.Reverse();
                var ts = new TimeSpan(0, 0, buf.ToInt());
                WriteLog("租约到期:{0}", ts);
            }
        }