internal DnsServerResponse(bool connectionOk,int id,DNS_RCode rcode,List<DNS_rr> answers,List<DNS_rr> authoritiveAnswers,List<DNS_rr> additionalAnswers)
		{
			m_Success             = connectionOk;
            m_ID                  = id;
			m_RCODE               = rcode;	
			m_pAnswers            = answers;
			m_pAuthoritiveAnswers = authoritiveAnswers;
			m_pAdditionalAnswers  = additionalAnswers;
		}
示例#2
0
 internal DnsServerResponse(bool connectionOk, int id, DNS_RCode rcode, List <DNS_rr> answers, List <DNS_rr> authoritiveAnswers, List <DNS_rr> additionalAnswers)
 {
     m_Success             = connectionOk;
     m_ID                  = id;
     m_RCODE               = rcode;
     m_pAnswers            = answers;
     m_pAuthoritiveAnswers = authoritiveAnswers;
     m_pAdditionalAnswers  = additionalAnswers;
 }
示例#3
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="rcode">DNS server returned error code.</param>
 public DNS_ClientException(DNS_RCode rcode)
     : base("Dns error: " + rcode + ".")
 {
     m_RCode = rcode;
 }
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="rcode">DNS server returned error code.</param>
 public DNS_ClientException(DNS_RCode rcode) : base("Dns error: " + rcode + ".")
 {
     m_RCode = rcode;
 }
示例#5
0
        /// <summary>
        /// Parses query.
        /// </summary>
        /// <param name="reply">Dns server reply.</param>
        /// <returns></returns>
        private DnsServerResponse ParseQuery(byte[] reply)
        {
            //--- Parse headers ------------------------------------//

            /* RFC 1035 4.1.1. Header section format
             *
             *                                                              1  1  1  1  1  1
             * 0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |                      ID                       |
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |QR|   Opcode  |AA|TC|RD|RA|   Z    |   RCODE   |
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |                    QDCOUNT                    |
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |                    ANCOUNT                    |
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |                    NSCOUNT                    |
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |                    ARCOUNT                    |
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |
             | QDCOUNT
             |      an unsigned 16 bit integer specifying the number of
             |      entries in the question section.
             |
             | ANCOUNT
             |      an unsigned 16 bit integer specifying the number of
             |      resource records in the answer section.
             |
             | NSCOUNT
             |      an unsigned 16 bit integer specifying the number of name
             |      server resource records in the authority records section.
             |
             | ARCOUNT
             |      an unsigned 16 bit integer specifying the number of
             |      resource records in the additional records section.
             |
             */

            // Get reply code
            int       id                     = (reply[0] << 8 | reply[1]);
            OPCODE    opcode                 = (OPCODE)((reply[2] >> 3) & 15);
            DNS_RCode replyCode              = (DNS_RCode)(reply[3] & 15);
            int       queryCount             = (reply[4] << 8 | reply[5]);
            int       answerCount            = (reply[6] << 8 | reply[7]);
            int       authoritiveAnswerCount = (reply[8] << 8 | reply[9]);
            int       additionalAnswerCount  = (reply[10] << 8 | reply[11]);
            //---- End of headers ---------------------------------//

            int pos = 12;

            //----- Parse question part ------------//
            for (int q = 0; q < queryCount; q++)
            {
                string dummy = "";
                GetQName(reply, ref pos, ref dummy);
                //qtype + qclass
                pos += 4;
            }
            //--------------------------------------//

            // 1) parse answers
            // 2) parse authoritive answers
            // 3) parse additional answers
            List <DNS_rr> answers            = ParseAnswers(reply, answerCount, ref pos);
            List <DNS_rr> authoritiveAnswers = ParseAnswers(reply, authoritiveAnswerCount, ref pos);
            List <DNS_rr> additionalAnswers  = ParseAnswers(reply, additionalAnswerCount, ref pos);

            return(new DnsServerResponse(true, id, replyCode, answers, authoritiveAnswers, additionalAnswers));
        }