Пример #1
0
        internal DnsResponse(DnsReader br)
        {
            _header = new DnsHeader(br);

            _numQuestions         = br.ReadInt16();
            _numAnswers           = br.ReadInt16();
            _numNameServers       = br.ReadInt16();
            _numAdditionalRecords = br.ReadInt16();

#if (MF)
            _questions         = new Question[_numQuestions];
            _answers           = new Answer[_numAnswers];
            _authorities       = new Authority[_numNameServers];
            _additionalRecords = new Additional[_numAdditionalRecords];
#endif


#if (MF)
            for (int i = 0; i < _numQuestions; i++)
            {
                _questions[i] = new Question(br);
            }

            for (int i = 0; i < _numAnswers; i++)
            {
                _answers[i] = new Answer(br);
            }

            for (int i = 0; i < _numNameServers; i++)
            {
                _authorities[i] = new Authority(br);
            }

            for (int i = 0; i < _numAdditionalRecords; i++)
            {
                _additionalRecords[i] = new Additional(br);
            }
#else
            for (int i = 0; i < _numQuestions; i++)
            {
                _questions.Add(new Question(br));
            }

            for (int i = 0; i < _numAnswers; i++)
            {
                _answers.Add(new Answer(br));
            }

            for (int i = 0; i < _numNameServers; i++)
            {
                _authorities.Add(new Authority(br));
            }

            for (int i = 0; i < _numAdditionalRecords; i++)
            {
                _additionalRecords.Add(new Additional(br));
            }
#endif
        }
Пример #2
0
        internal ResourceRecord(DnsReader br)
        {
            _domain = br.ReadDomain();
            _qtype  = (DnsType)br.ReadInt16();
            _qclass = (DnsClass)br.ReadInt16();
            _ttl    = br.ReadInt32();

            int recordLength = br.ReadInt16();

            if (recordLength != 0)
            {
                switch (_qtype)
                {
                case DnsType.A:     _record = new ARecord(br);      break;

                case DnsType.CNAME: _record = new CNAMERecord(br);  break;

                case DnsType.MX:    _record = new MXRecord(br);     break;

                case DnsType.NS:    _record = new NSRecord(br);     break;

                case DnsType.SOA:   _record = new SOARecord(br);    break;

                case DnsType.TXT:   _record = new TXTRecord(br);    break;

                case DnsType.PTR:       _record = new PTRERecord(br);   break;

                // NetBIOS related records
                case DnsType.NB:    _record = new NBRecord(br);     break;

                default:
                    br += recordLength;
                    break;
                }
            }
        }
Пример #3
0
 internal Question(DnsReader br)
 {
     _domain = br.ReadDomain();
     _qtype  = (DnsType)br.ReadInt16();
     _qclass = (DnsClass)br.ReadInt16();
 }
Пример #4
0
 internal MXRecord(DnsReader br)
 {
     _preference = br.ReadInt16();
     _domainName = br.ReadDomain();
 }