Beispiel #1
0
        /// <summary>
        /// Processes received UDP packet.
        /// </summary>
        /// <param name="e">UDP packet.</param>
        private void ProcessUdpPacket(UDP_e_PacketReceived e)
        {
            try
            {
                if (m_IsDisposed)
                {
                    return;
                }

                DnsServerResponse     serverResponse = ParseQuery(e.Buffer);
                DNS_ClientTransaction transaction    = null;
                // Pass response to transaction.
                if (m_pTransactions.TryGetValue(serverResponse.ID, out transaction))
                {
                    if (transaction.State == DNS_ClientTransactionState.Active)
                    {
                        // Cache query.
                        if (m_UseDnsCache && serverResponse.ResponseCode == DNS_RCode.NO_ERROR)
                        {
                            DnsCache.AddToCache(transaction.QName, (int)transaction.QType, serverResponse);
                        }

                        transaction.ProcessResponse(serverResponse);
                    }
                }
                // No such transaction or transaction has timed out before answer received.
                //else{
                //}
            }
            catch
            {
                // We don't care about receiving errors here, skip them.
            }
        }
        /// <summary>
        /// This method is called when flow gets new UDP packet.
        /// </summary>
        /// <param name="e">Event data..</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>e</b> is null reference.</exception>
        internal void OnUdpPacketReceived(UDP_e_PacketReceived e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            m_LastActivity = DateTime.Now;

            byte[] data = new byte[e.Count];
            Array.Copy(e.Buffer, data, e.Count);

            m_pStack.TransportLayer.OnMessageReceived(this, data);
        }