コード例 #1
0
ファイル: DhcpServer.cs プロジェクト: prog76/SoftGetaway
        private void OnReceive(IAsyncResult result)
        {
            DhcpData data = new DhcpData((Byte[])result.AsyncState);

            data.Result = result;

            if (!this.m_Abort)
            {
                Trace.TraceInformation("Dhcp Messages Received, Queued for Processing.");

                // Queue this request for processing
                ThreadPool.QueueUserWorkItem(new WaitCallback(this.CompleteRequest), data);

                this.Listen();
            }
        }
コード例 #2
0
ファイル: DhcpServer.cs プロジェクト: prog76/SoftGetaway
        private void OnReceive(IAsyncResult result)
        {
            DhcpData data = new DhcpData((Byte[])result.AsyncState);
            data.Result = result;

            if (!this.m_Abort)
            {
                Trace.TraceInformation("Dhcp Messages Received, Queued for Processing.");

                // Queue this request for processing
                ThreadPool.QueueUserWorkItem(new WaitCallback(this.CompleteRequest), data);

                this.Listen();
            }
        }
コード例 #3
0
ファイル: DhcpServer.cs プロジェクト: prog76/SoftGetaway
        private void CompleteRequest(Object state)
        {
            DhcpData messageData = (DhcpData)state;
            EndPoint source      = new IPEndPoint(0, 0);

            this.m_AbortLock.AcquireReaderLock(-1);

            try {
                if (this.m_Abort)
                {
                    return;
                }
                messageData.BufferSize = this.m_DhcpSocket.EndReceiveFrom(messageData.Result, ref source);
                messageData.Source     = (IPEndPoint)source;
            } catch (ArgumentException ex) {
                Trace.TraceInformation("DHCP: " + ex.Message);
                return;
            } finally
            {
                this.m_AbortLock.ReleaseLock();
            }

            DhcpMessage message;

            try
            {
                message = new DhcpMessage(messageData);
            }
            catch (ArgumentException ex)
            {
                TraceException("Error Parsing Dhcp Message", ex);
                return;
            }
            catch (InvalidCastException ex)
            {
                TraceException("Error Parsing Dhcp Message", ex);
                return;
            }
            catch (IndexOutOfRangeException ex)
            {
                TraceException("Error Parsing Dhcp Message", ex);
                return;
            }
            catch (Exception ex)
            {
                TraceException("Error Parsing Dhcp Message", ex);
                throw;
            }

            if (message.Operation == DhcpOperation.BootRequest)
            {
                Byte[] messageTypeData = message.GetOptionData(DhcpOption.DhcpMessageType);

                if (messageTypeData != null && messageTypeData.Length == 1)
                {
                    DhcpMessageType messageType = (DhcpMessageType)messageTypeData[0];

                    switch (messageType)
                    {
                    case DhcpMessageType.Discover:
                        Trace.TraceInformation("{0} Dhcp DISCOVER Message Received.", Thread.CurrentThread.ManagedThreadId);
                        this.DhcpDiscover(message);
                        Trace.TraceInformation("{0} Dhcp DISCOVER Message Processed.", Thread.CurrentThread.ManagedThreadId);
                        break;

                    case DhcpMessageType.Request:
                        Trace.TraceInformation("{0} Dhcp REQUEST Message Received.", Thread.CurrentThread.ManagedThreadId);
                        this.DhcpRequest(message);
                        Trace.TraceInformation("{0} Dhcp REQUEST Message Processed.", Thread.CurrentThread.ManagedThreadId);
                        break;

                    default:
                        Trace.TraceWarning("Unknown Dhcp Message ({0}) Received, Ignoring.", messageType.ToString());
                        break;
                    }
                }
                else
                {
                    Trace.TraceWarning("Unknown Dhcp Data Received, Ignoring.");
                }
            }
        }
コード例 #4
0
ファイル: DhcpMessage.cs プロジェクト: prog76/SoftGetaway
 internal DhcpMessage(DhcpData data)
     : this(data.MessageBuffer)
 {
 }
コード例 #5
0
ファイル: DhcpMessage.cs プロジェクト: wlbwwh/WinDHCP
 internal DhcpMessage(DhcpData data)
     : this(data.MessageBuffer)
 {
 }