コード例 #1
0
 internal DnsServerResponse(bool connectionOk, RCODE rcode, List <DNS_rr_base> answers, List <DNS_rr_base> authoritiveAnswers, List <DNS_rr_base> additionalAnswers)
 {
     m_Success             = connectionOk;
     m_RCODE               = rcode;
     m_pAnswers            = answers;
     m_pAuthoritiveAnswers = authoritiveAnswers;
     m_pAdditionalAnswers  = additionalAnswers;
 }
コード例 #2
0
 internal DnsServerResponse(bool connectionOk,RCODE rcode,ArrayList answers,ArrayList authoritiveAnswers,ArrayList additionalAnswers)
 {
     m_Success             = connectionOk;
     m_RCODE               = rcode;
     m_pAnswers            = answers;
     m_pAuthoritiveAnswers = authoritiveAnswers;
     m_pAdditionalAnswers  = additionalAnswers;
 }
コード例 #3
0
 internal DnsServerResponse(bool connectionOk,RCODE rcode,List<DnsRecordBase> answers,List<DnsRecordBase> authoritiveAnswers,List<DnsRecordBase> additionalAnswers)
 {
     m_Success             = connectionOk;
     m_RCODE               = rcode;
     m_pAnswers            = answers;
     m_pAuthoritiveAnswers = authoritiveAnswers;
     m_pAdditionalAnswers  = additionalAnswers;
 }
コード例 #4
0
 internal DnsServerResponse(bool connectionOk, RCODE rcode, ArrayList answers, ArrayList authoritiveAnswers, ArrayList additionalAnswers)
 {
     m_Success             = connectionOk;
     m_RCODE               = rcode;
     m_pAnswers            = answers;
     m_pAuthoritiveAnswers = authoritiveAnswers;
     m_pAdditionalAnswers  = additionalAnswers;
 }
コード例 #5
0
ファイル: DnsHeader.cs プロジェクト: u314B/open.etaxbill.core
        internal bool ParseHeader(byte[] query)
        {
            try
            {
                /*
                 *                              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.
                 */

                //----- Parse query headers -----------------------------//
                // Get reply code
                var id          = (query[0] << 8 | query[1]);
                var opcode      = ((query[2] >> 3) & 15);
                var replyCode   = (query[3] & 15);
                var queryCount  = (query[4] << 8 | query[5]);
                var answerCount = (query[6] << 8 | query[7]);
                var nsCount     = (query[8] << 8 | query[9]);
                var arCount     = (query[10] << 8 | query[11]);
                //-------------------------------------------------------//

                m_QID     = id;
                m_OPCODE  = (OPCODE)opcode;
                m_RCODE   = (RCODE)replyCode;
                m_QDCOUNT = queryCount;
                m_ANCOUNT = answerCount;
                m_NSCOUNT = nsCount;
                m_ARCOUNT = arCount;

                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #6
0
            public RCODE reportError(
                ref RestoreAction peRestoreAction,
                RCODE rcErr)
            {
                peRestoreAction = RestoreAction.XFLM_RESTORE_ACTION_CONTINUE;

                System.Console.WriteLine("\nError reported: {0}", rcErr);
                m_bOutputLines = true;
                return(RCODE.NE_XFLM_OK);
            }
コード例 #7
0
ファイル: Header.cs プロジェクト: Moerty/dnstools
        public override string ToString()
        {
            switch (QR)
            {
            case DNS.QR.Q:
                return(string.Format("Request: {0}",
                                     OPCODE.ToString()
                                     ));

            case DNS.QR.R:
                return(string.Format("{0}: {1} RD={2} RA={3} {4} {5}",
                                     (AA ? "Authoritative Response" : "Non-Authoritative Response"),
                                     OPCODE.ToString(),
                                     (RD ? "1" : "0"),
                                     (RA ? "1" : "0"),
                                     RCODE.ToString(),
                                     (TC ? "TRUNCATED " : "")
                                     ));
            }
            // throw new InvalidOperationException("Unexpected QR value.");
            // CA1065	Do not raise exceptions in unexpected locations
            return(null);
        }
コード例 #8
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="rcode">DNS server returned error code.</param>
 public DNS_ClientException(RCODE rcode) : base("Dns error: " + rcode + ".")
 {
     m_RCode = rcode;
 }
コード例 #9
0
        internal bool ParseHeader(byte[] query)
        {
            try
            {
                /*
                                                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.
                */

                //----- Parse query headers -----------------------------//
                // Get reply code
                int id          = (query[0]  << 8 | query[1]);
                int opcode      = ((query[2] >> 3) & 15);
                int replyCode   = (query[3]  & 15);
                int queryCount  = (query[4]  << 8 | query[5]);
                int answerCount = (query[6]  << 8 | query[7]);
                int nsCount     = (query[8]  << 8 | query[9]);
                int arCount     = (query[10] << 8 | query[11]);
                //-------------------------------------------------------//

                m_QID     = id;
                m_OPCODE  = (OPCODE)opcode;
                m_RCODE   = (RCODE)replyCode;
                m_QDCOUNT = queryCount;
                m_ANCOUNT = answerCount;
                m_NSCOUNT = nsCount;
                m_ARCOUNT = arCount;

                return true;
            }
            catch{
                return false;
            }
        }
コード例 #10
0
ファイル: DnsException.cs プロジェクト: queueit/Dns
 public DnsException(RCODE responseCode, string message)
     : base(message)
 {
     this.ResponseCode = responseCode;
 }
コード例 #11
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="rcode">DNS server returned error code.</param>
 public DNS_ClientException(RCODE rcode)
 {
     m_RCode = rcode;
 }
コード例 #12
0
 internal DnsServerResponse(bool connectionOk, RCODE rcode, ArrayList answers)
 {
     m_Success  = connectionOk;
     m_pRCODE   = rcode;
     m_pAnswers = answers;
 }
コード例 #13
0
        /// <summary>
        /// XFLAIM Exception that returns a message.
        /// </summary>
        /// <param name="message">Message explaining cause of exception.</param>
        public XFlaimException(
			string 		message)
        {
            m_message = message;
            m_rc = 0;
        }
コード例 #14
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="rcode">DNS server returned error code.</param>
 public DNS_ClientException(RCODE rcode)
 {
     m_RCode = rcode;
 }
コード例 #15
0
ファイル: Dns_Client.cs プロジェクト: ramonsmits/emailsender
        /// <summary>
        /// Parses answer.
        /// </summary>
        /// <param name="reply"></param>
        /// <param name="queryID"></param>
        /// <returns>Returns Dns_Answer[] collection if answer parsed successfully or throws exception if failed.</returns>
        private DnsServerResponse ParseAnswers(byte[] reply, int queryID)
        {
            //--- Parse headers ------------------------------------//

            /*
             *                                                              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.
             */

            // Get reply code
            int    id          = (reply[0] << 8 | reply[1]);
            OPCODE opcode      = (OPCODE)((reply[2] >> 3) & 15);
            RCODE  replyCode   = (RCODE)(reply[3] & 15);
            int    queryCount  = (reply[4] << 8 | reply[5]);
            int    answerCount = (reply[6] << 8 | reply[7]);
            int    nsCount     = (reply[8] << 8 | reply[9]);
            int    arCount     = (reply[10] << 8 | reply[11]);

            //---- End of headers ---------------------------------//

            // Check that it's query what we want
            if (queryID != id)
            {
                throw new Exception("This isn't query with ID what we expected");
            }

            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  1  1  1  1  1
             * 0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |                                               |
             | /                                               /
             | /                      NAME                     /
             |                                               |
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |                      TYPE                     |
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |                     CLASS                     |
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |                      TTL                      |
             |                                               |
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |                   RDLENGTH                    |
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
             | /                     RDATA                     /
             | /                                               /
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             */

            ArrayList answers = new ArrayList();

            //---- Start parsing aswers ------------------------------------------------------------------//
            for (int i = 0; i < answerCount; i++)
            {
                string name = "";
                if (!GetQName(reply, ref pos, ref name))
                {
                    throw new Exception("Error parisng anser");
                }

                int type     = reply[pos++] << 8 | reply[pos++];
                int rdClass  = reply[pos++] << 8 | reply[pos++];
                int ttl      = reply[pos++] << 24 | reply[pos++] << 16 | reply[pos++] << 8 | reply[pos++];
                int rdLength = reply[pos++] << 8 | reply[pos++];

                object answerObj = null;
                switch ((QTYPE)type)
                {
                case QTYPE.A:
                    answerObj = ParseARecord(reply, ref pos, rdLength);
                    pos      += rdLength;
                    break;

                case QTYPE.NS:
                    answerObj = ParseNSRecord(reply, ref pos, rdLength);
                    //	pos += rdLength;
                    break;

                case QTYPE.CNAME:
                    answerObj = ParseCNAMERecord(reply, ref pos, rdLength);
                    //	pos += rdLength;
                    break;

                case QTYPE.PTR:
                    answerObj = ParsePTRRecord(reply, ref pos, rdLength);
                    //	pos += rdLength;
                    break;

                case QTYPE.MX:
                    answerObj = ParseMxRecord(reply, ref pos);
                    break;

                case QTYPE.TXT:
                    answerObj = ParseTXTRecord(reply, ref pos, rdLength);
                    break;

                case QTYPE.AAAA:
                    answerObj = ParseAAAARecord(reply, ref pos, rdLength);
                    pos      += rdLength;
                    break;

                default:
                    answerObj = "dummy";                             // Dummy place holder for now
                    pos      += rdLength;
                    break;
                }

                // Add answer to answer list
                if (answerObj != null)
                {
                    answers.Add(answerObj);
                }
            }
            //-------------------------------------------------------------------------------------------//

            return(new DnsServerResponse(true, replyCode, answers));
        }
コード例 #16
0
ファイル: Db.cs プロジェクト: Tyrion-Lannister-274AL/flaim
        private static extern void xflaim_Db_setMustAbortTrans(
			IntPtr	pDb,
			RCODE		rc);
コード例 #17
0
ファイル: Db.cs プロジェクト: Tyrion-Lannister-274AL/flaim
        //-----------------------------------------------------------------------------
        // setMustAbortTrans
        //-----------------------------------------------------------------------------
        /// <summary>
        /// Force the current transaction to abort.  This method should be called
        /// when the code should not be the code that aborts the transation, but
        /// wants to require that the transaction be aborted by whatever module has
        /// the authority to abort the transaction.  An error code may be
        /// set to indicate what error condition is causing the transaction to be
        /// aborted.
        /// </summary>
        /// <param name="rc">
        /// Error code that indicates why the transaction is aborting.
        /// </param>
        public void setMustAbortTrans(
			RCODE		rc)
        {
            xflaim_Db_setMustAbortTrans( m_pDb, rc);
        }
コード例 #18
0
            public RCODE reportError(
				ref RestoreAction 	peRestoreAction,
				RCODE						rcErr)
            {
                peRestoreAction = RestoreAction.XFLM_RESTORE_ACTION_CONTINUE;

                System.Console.WriteLine( "\nError reported: {0}", rcErr);
                m_bOutputLines = true;
                return( RCODE.NE_XFLM_OK);
            }
コード例 #19
0
        /// <summary>
        /// Parses query.
        /// </summary>
        /// <param name="reply">Dns server reply.</param>
        /// <param name="queryID">Query id of sent query.</param>
        /// <returns></returns>
        private DnsServerResponse ParseQuery(byte[] reply, int queryID)
        {
            //--- 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);
            RCODE  replyCode              = (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 ---------------------------------//

            // Check that it's query what we want
            if (queryID != id)
            {
                throw new Exception("This isn't query with ID what we expected");
            }

            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_base> answers            = ParseAnswers(reply, answerCount, ref pos);
            List <DNS_rr_base> authoritiveAnswers = ParseAnswers(reply, authoritiveAnswerCount, ref pos);
            List <DNS_rr_base> additionalAnswers  = ParseAnswers(reply, additionalAnswerCount, ref pos);

            return(new DnsServerResponse(true, replyCode, answers, authoritiveAnswers, additionalAnswers));
        }
コード例 #20
0
        /// <summary>
        /// XFLAIM Exception that returns an RCODE.
        /// </summary>
        /// <param name="rc">The error code that occurred.</param>
        public XFlaimException( 
			RCODE	rc)
        {
            m_rc = rc;
            m_message = null;
        }