Ejemplo n.º 1
0
 public RR(RecordReader rr)
 {
     TimeLived = 0;
     NAME      = rr.ReadDomainName();
     Type      = (RecordType)rr.ReadUInt16();
     Class     = (Class)rr.ReadUInt16();
     TTL       = rr.ReadUInt32();
     RDLENGTH  = rr.ReadUInt16();
     RECORD    = rr.ReadRecord(this, Type);
 }
Ejemplo n.º 2
0
        public Response(IPEndpoint endpoint, byte[] data)
        {
            Error = String.Empty;
            Server = endpoint;
            TimeStamp = DateTime.Now;
            MessageSize = data.Length;
            RecordReader rr = new RecordReader(data);

            Questions = new List<Question>();
            Answers = new List<AnswerRR>();
            Authorities = new List<AuthorityRR>();
            Additionals = new List<AdditionalRR>();

            header = new Header(rr);

            //if (header.RCODE != RCode.NoError)
            //	Error = header.RCODE.ToString();

            for (int intI = 0; intI < header.QDCOUNT; intI++)
            {
                Questions.Add(new Question(rr));
            }

            for (int intI = 0; intI < header.ANCOUNT; intI++)
            {
                Answers.Add(new AnswerRR(rr));
            }

            for (int intI = 0; intI < header.NSCOUNT; intI++)
            {
                Authorities.Add(new AuthorityRR(rr));
            }
            for (int intI = 0; intI < header.ARCOUNT; intI++)
            {
                Additionals.Add(new AdditionalRR(rr));
            }
        }
Ejemplo n.º 3
0
        public Response(IPEndpoint endpoint, byte[] data)
        {
            Error       = String.Empty;
            Server      = endpoint;
            TimeStamp   = DateTime.Now;
            MessageSize = data.Length;
            RecordReader rr = new RecordReader(data);

            Questions   = new List <Question>();
            Answers     = new List <AnswerRR>();
            Authorities = new List <AuthorityRR>();
            Additionals = new List <AdditionalRR>();

            header = new Header(rr);

            //if (header.RCODE != RCode.NoError)
            //	Error = header.RCODE.ToString();

            for (int intI = 0; intI < header.QDCOUNT; intI++)
            {
                Questions.Add(new Question(rr));
            }

            for (int intI = 0; intI < header.ANCOUNT; intI++)
            {
                Answers.Add(new AnswerRR(rr));
            }

            for (int intI = 0; intI < header.NSCOUNT; intI++)
            {
                Authorities.Add(new AuthorityRR(rr));
            }
            for (int intI = 0; intI < header.ARCOUNT; intI++)
            {
                Additionals.Add(new AdditionalRR(rr));
            }
        }
Ejemplo n.º 4
0
 public Header(RecordReader rr)
 {
     ID = rr.ReadUInt16();
     Flags = rr.ReadUInt16();
     QDCOUNT = rr.ReadUInt16();
     ANCOUNT = rr.ReadUInt16();
     NSCOUNT = rr.ReadUInt16();
     ARCOUNT = rr.ReadUInt16();
 }
Ejemplo n.º 5
0
 public Question(RecordReader rr)
 {
     QName  = rr.ReadDomainName();
     QType  = (QType)rr.ReadUInt16();
     QClass = (QClass)rr.ReadUInt16();
 }
Ejemplo n.º 6
0
 public AdditionalRR(RecordReader br)
     : base(br)
 {
 }
Ejemplo n.º 7
0
 public AuthorityRR(RecordReader br)
     : base(br)
 {
 }
Ejemplo n.º 8
0
 public AnswerRR(RecordReader br)
     : base(br)
 {
 }
Ejemplo n.º 9
0
 public RR(RecordReader rr)
 {
     TimeLived = 0;
     NAME = rr.ReadDomainName();
     Type = (RecordType)rr.ReadUInt16();
     Class = (Class)rr.ReadUInt16();
     TTL = rr.ReadUInt32();
     RDLENGTH = rr.ReadUInt16();
     RECORD = rr.ReadRecord(this, Type);
 }
Ejemplo n.º 10
0
 public Question(RecordReader rr)
 {
     QName = rr.ReadDomainName();
     QType = (QType)rr.ReadUInt16();
     QClass = (QClass)rr.ReadUInt16();
 }
Ejemplo n.º 11
0
        public string ReadDomainName()
        {
            StringBuilder name = new StringBuilder();
            int length = 0;

            // get  the length of the first label
            while ((length = ReadByte()) != 0)
            {
                // top 2 bits set denotes domain name compression and to reference elsewhere
                if ((length & 0xc0) == 0xc0)
                {
                    // work out the existing domain name, copy this pointer
                    RecordReader newRecordReader = new RecordReader(m_Data, (length & 0x3f) << 8 | ReadByte());

                    name.Append(newRecordReader.ReadDomainName());
                    return name.ToString();
                }

                // if not using compression, copy a char at a time to the domain name
                while (length > 0)
                {
                    name.Append(ReadChar());
                    length--;
                }
                name.Append('.');
            }
            if (name.Length == 0)
                return ".";
            else
                return name.ToString();
        }
Ejemplo n.º 12
0
 public AdditionalRR(RecordReader br)
     : base(br)
 {
 }
Ejemplo n.º 13
0
 public AuthorityRR(RecordReader br)
     : base(br)
 {
 }
Ejemplo n.º 14
0
 public AnswerRR(RecordReader br)
     : base(br)
 {
 }