Beispiel #1
0
        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);
                }
            }
        }
Beispiel #2
0
 public Question(DataBuffer buffer)
 {
     _domain    = buffer.ReadDomainName();
     _recType   = (RecordType)buffer.ReadBEShortInt();
     _classType = buffer.ReadBEShortInt();
 }
Beispiel #3
0
 public Question(DataBuffer buffer)
 {
     _domain = buffer.ReadDomainName();
     _recType = (RecordType)buffer.ReadBEShortInt();
     _classType = buffer.ReadBEShortInt();
 }
Beispiel #4
0
        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);
                }
            }
        }
Beispiel #5
0
 public PrefAndDomain(DataBuffer buffer)
 {
     _preference = buffer.ReadBEShortInt();
     _domain     = buffer.ReadDomainName();
 }
Beispiel #6
0
 public PrefAndDomain(DataBuffer buffer)
 {
     _preference = buffer.ReadBEShortInt();
     _domain = buffer.ReadDomainName();
 }