Exemplo n.º 1
0
        /// <summary>
        /// Create a Question record for Dns Answer
        /// </summary>
        /// <param name="buffer"></param>
        public Question(DataBuffer buffer)
        {
            domain = buffer.ReadDomainName();
            recType = (RecordType)buffer.ReadBEShortInt();
            classType = buffer.ReadBEShortInt();

        }
Exemplo n.º 2
0
 /// <summary>
 /// Common class for all record types that contain a preference and a domain name
 /// </summary>
 /// <param name="buffer"></param>
 public PrefAndDomain(DataBuffer buffer)
 {
     preference = buffer.ReadBEShortInt();
     domain = buffer.ReadDomainName();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Given a byte array  interpret them as a DnsEntry
        /// </summary>
        /// <param name="response"></param>
        public DnsAnswer(byte[] response)
        {
            questions  = new List <Question>();
            answers    = new List <Answer>();
            servers    = new List <Server>();
            additional = new List <Record>();
            exceptions = new List <Exception>();
            DataBuffer buffer = new DataBuffer(response, 2);
            byte       bits1  = buffer.ReadByte();
            byte       bits2  = buffer.ReadByte();
            //Mask off return code
            int returnCode = bits2 & 15;

            if (returnCode > 6)
            {
                returnCode = 6;
            }
            this.returnCode = (ReturnCode)returnCode;
            //Get Additional Flags
            authoritative = TestBit(bits1, 2);
            recursive     = TestBit(bits2, 8);
            truncated     = TestBit(bits1, 1);

            int nQuestions  = buffer.ReadBEShortInt();
            int nAnswers    = buffer.ReadBEShortInt();
            int nServers    = buffer.ReadBEShortInt();
            int nAdditional = buffer.ReadBEShortInt();

            //read in questions
            for (int i = 0; i < nQuestions; i++)
            {
                try
                {
                    questions.Add(new Question(buffer));
                }
                catch (Exception ex)
                {
                    exceptions.Add(ex);
                }
            }
            //read in answers
            for (int i = 0; i < nAnswers; i++)
            {
                try
                {
                    answers.Add(new Answer(buffer));
                }
                catch (Exception ex)
                {
                    exceptions.Add(ex);
                }
            }
            //read in servers
            for (int i = 0; i < nServers; i++)
            {
                try
                {
                    servers.Add(new Server(buffer));
                }
                catch (Exception ex)
                {
                    exceptions.Add(ex);
                }
            }
            //read in additional records
            for (int i = 0; i < nAdditional; i++)
            {
                try
                {
                    additional.Add(new Record(buffer));
                }
                catch (Exception ex)
                {
                    exceptions.Add(ex);
                }
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Create a Question record for Dns Answer
 /// </summary>
 /// <param name="buffer"></param>
 public Question(DataBuffer buffer)
 {
     domain    = buffer.ReadDomainName();
     recType   = (RecordType)buffer.ReadBEShortInt();
     classType = buffer.ReadBEShortInt();
 }
Exemplo n.º 5
0
        /// <summary>
        /// Given a byte array  interpret them as a DnsEntry  
        /// </summary>
        /// <param name="response"></param>
        public DnsAnswer(byte[] response)
        {
            questions = new List<Question>();
            answers = new List<Answer>();
            servers = new List<Server>();
            additional = new List<Record>();
            exceptions = new List<Exception>();
            DataBuffer buffer = new DataBuffer(response, 2);
            byte bits1 = buffer.ReadByte();
            byte bits2 = buffer.ReadByte();
            //Mask off return code
            int returnCode = bits2 & 15;
            if (returnCode > 6)  returnCode = 6;
            this.returnCode = (ReturnCode)returnCode;
            //Get Additional Flags
            authoritative = TestBit(bits1, 2);
            recursive = TestBit(bits2, 8);
            truncated = TestBit(bits1, 1);

            int nQuestions  = buffer.ReadBEShortInt();
            int nAnswers    = buffer.ReadBEShortInt();
            int nServers    = buffer.ReadBEShortInt();
            int nAdditional = buffer.ReadBEShortInt();
            
            //read in questions
            for(int i = 0; i < nQuestions; i++)
            {
                try
                {
                    questions.Add(new Question(buffer));
                }
                catch (Exception ex)
                {                    
                    exceptions.Add(ex);
                }
            }
            //read in answers
            for(int i = 0; i < nAnswers; i++)
            {
                try
                {
                    answers.Add(new Answer(buffer));
                }
                catch (Exception ex)
                {
                    exceptions.Add(ex);
                }
            }
            //read in servers
            for(int i = 0; i < nServers; i++)
            {
                try
                {
                    servers.Add(new Server(buffer));
                }
                catch (Exception ex)
                {
                    exceptions.Add(ex);
                }
            }
            //read in additional records 
            for(int i = 0; i < nAdditional; i++)
            {
                try
                {
                    additional.Add(new Record(buffer));
                }
                catch (Exception ex)
                {
                    exceptions.Add(ex);
                }
            }            
        }
Exemplo n.º 6
0
 /// <summary>
 /// Common class for all record types that contain a preference and a domain name
 /// </summary>
 /// <param name="buffer"></param>
 public PrefAndDomain(DataBuffer buffer)
 {
     preference = buffer.ReadBEShortInt();
     domain     = buffer.ReadDomainName();
 }