Exemplo n.º 1
0
        private void OnReceive(IAsyncResult result)
        {
            DhcpData data = new DhcpData((Byte[])result.AsyncState);

            data.Result = result;
            // Queue this request for processing
            ThreadPool.QueueUserWorkItem(new WaitCallback(this.CompleteRequest), data);
            ReceiveData();
        }
Exemplo n.º 2
0
        private void CompleteRequest(object o)
        {
            DhcpData messageData = (DhcpData)o;
            EndPoint source      = new IPEndPoint(IPAddress.Any, 0);

            try
            {
                _socket.EndReceiveFrom(messageData.Result, ref source);
                messageData.Source = (IPEndPoint)source;
                var dhcpRequest = new DHCPRequest(messageData.MessageBuffer, _socket, messageData.Source, this);

                OnDataReceived(dhcpRequest);
                var msgType = dhcpRequest.GetMsgType();

                switch (msgType)
                {
                case DHCPMsgType.DHCPDISCOVER:
                    OnDiscover(dhcpRequest);
                    break;

                case DHCPMsgType.DHCPREQUEST:
                    OnRequest(dhcpRequest);
                    break;

                case DHCPMsgType.DHCPINFORM:
                    OnInform(dhcpRequest);
                    break;

                default:
                    Trace.WriteLine("Message Type Not Handled By CloneDeploy Proxy DHCP - Ignoring Request");
                    break;
                }
            }
            catch
            {
                //throw;
            }
        }