コード例 #1
0
        ///<summary>
        ///</summary>
        ///<returns></returns>
        public string ReadDomainName()
        {
            var name = new StringBuilder();
            int length;

            // 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
                    var newRecordReader = new RecordReader(_mData, (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('.');
            }
            return(name.Length == 0 ? "." : name.ToString());
        }
コード例 #2
0
ファイル: RR.cs プロジェクト: zhouDongXing/xmpp
 ///<summary>
 ///</summary>
 ///<param name="rr"></param>
 public RR(RecordReader rr)
 {
     TimeLived = 0;
     Name      = rr.ReadDomainName();
     Type      = (Type)rr.ReadUInt16();
     Class     = (Class)rr.ReadUInt16();
     TTL       = rr.ReadUInt32();
     RDLENGTH  = rr.ReadUInt16();
     Record    = rr.ReadRecord(Type);
     Record.RR = this;
 }
コード例 #3
0
 ///<summary>
 ///</summary>
 ///<param name="rr"></param>
 public Question(RecordReader rr)
 {
     QName  = rr.ReadDomainName();
     QType  = (QType)rr.ReadUInt16();
     QClass = (QClass)rr.ReadUInt16();
 }
コード例 #4
0
ファイル: Question.cs プロジェクト: sstraus/xmpp
 ///<summary>
 ///</summary>
 ///<param name="rr"></param>
 public Question(RecordReader rr)
 {
     QName = rr.ReadDomainName();
     QType = (QType) rr.ReadUInt16();
     QClass = (QClass) rr.ReadUInt16();
 }
コード例 #5
0
ファイル: RecordReader.cs プロジェクト: sstraus/xmpp
        ///<summary>
        ///</summary>
        ///<returns></returns>
        public string ReadDomainName()
        {
            var name = new StringBuilder();
            int length;

            // 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
                    var newRecordReader = new RecordReader(_mData, (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('.');
            }
            return name.Length == 0 ? "." : name.ToString();
        }
コード例 #6
0
ファイル: RR.cs プロジェクト: sstraus/xmpp
 ///<summary>
 ///</summary>
 ///<param name="rr"></param>
 public RR(RecordReader rr)
 {
     TimeLived = 0;
     Name = rr.ReadDomainName();
     Type = (Type) rr.ReadUInt16();
     Class = (Class) rr.ReadUInt16();
     TTL = rr.ReadUInt32();
     RDLENGTH = rr.ReadUInt16();
     Record = rr.ReadRecord(Type);
     Record.RR = this;
 }