Esempio n. 1
0
 public override void WriteTo(Stream writer)
 {
     BinaryHelper.Write(writer, ((ushort)(6 + Target.GetByteCount())));
     BinaryHelper.Write(writer, Priority);
     BinaryHelper.Write(writer, Weight);
     BinaryHelper.Write(writer, Port);
     Target.WriteTo(writer);
 }
Esempio n. 2
0
        public override void WriteTo(Stream writer)
        {
            ushort length = Length;

            BinaryHelper.Write(writer, length);

            if (length > 0)
            {
                BinaryHelper.Write(writer, Bytes);
            }
        }
Esempio n. 3
0
 public void WriteTo(Stream stream)
 {
     DomainName.WriteTo(stream);
     BinaryHelper.Write(stream, (ushort)Type);
     BinaryHelper.Write(stream, (ushort)Class);
     BinaryHelper.Write(stream, Ttl);
     if (ResponseData != null)
     {
         ResponseData.WriteTo(stream);
     }
 }
Esempio n. 4
0
        public override void WriteTo(Stream stream)
        {
            //ID
            BinaryHelper.Write(stream, this.ID);

            //Qr, Opcode, Aa, Tc, Rd
            byte b = 0;

            b += (byte)this.QueryResponse;
            b  = (byte)(b << 4);
            b += (byte)this.OpCode;
            b  = (byte)(b << 1);
            b += (this.AuthoritativeAnswer) ? (byte)1 : (byte)0;
            b  = (byte)(b << 1);
            b += (this.Truncated) ? (byte)1 : (byte)0;
            b  = (byte)(b << 1);
            b += (this.RecursionDesired) ? (byte)1 : (byte)0;
            stream.WriteByte(b);

            //Ra, Z, Rcode
            b  = 0;
            b += (this.RecursionAvailable) ? (byte)1 : (byte)0;
            b  = (byte)(b << 7);
            b += (byte)this.ResponseCode;
            stream.WriteByte(b);

            BinaryHelper.Write(stream, QuestionEntries);
            BinaryHelper.Write(stream, AnswerEntries);
            BinaryHelper.Write(stream, AuthorityEntries);
            BinaryHelper.Write(stream, AdditionalEntries);

            foreach (Question q in Questions)
            {
                q.WriteTo(stream);
            }

            foreach (Answer a in Answers)
            {
                a.WriteTo(stream);
            }

            foreach (Answer a in Authorities)
            {
                a.WriteTo(stream);
            }

            foreach (Answer a in Additionals)
            {
                a.WriteTo(stream);
            }
        }
Esempio n. 5
0
 public void WriteTo(Stream stream)
 {
     foreach (string label in this)
     {
         if (label.Length == 0)
         {
             break;
         }
         byte[] bytes = Encoding.UTF8.GetBytes(label);
         //labels.Add(new KeyValuePair<byte[], byte>(bytes, (byte)bytes.Length));
         //totalLength += (ushort)(bytes.Length + 1);
         stream.WriteByte((byte)bytes.Length);
         BinaryHelper.Write(stream, bytes);
     }
     stream.WriteByte(0);
 }
Esempio n. 6
0
        public override void WriteTo(Stream writer)
        {
            ushort length = 0;
            List <KeyValuePair <byte[], byte> > bytes = new List <KeyValuePair <byte[], byte> >();

            foreach (KeyValuePair <string, string> kvp in Properties)
            {
                byte[] kvpBytes = Encoding.UTF8.GetBytes(kvp.Key + "=" + kvp.Value);
                bytes.Add(new KeyValuePair <byte[], byte>(kvpBytes, (byte)kvpBytes.Length));
                //writer.Write((byte)kvpBytes.Length);
                //writer.Write(kvpBytes);
                length += (ushort)kvpBytes.Length;
                length++;
            }
            BinaryHelper.Write(writer, length);
            foreach (var properties in bytes)
            {
                writer.WriteByte(properties.Value);
                BinaryHelper.Write(writer, properties.Key);
            }
        }
Esempio n. 7
0
 public override void WriteTo(Stream writer)
 {
     BinaryHelper.Write(writer, DomainName.GetByteCount());
     DomainName.WriteTo(writer);
 }
Esempio n. 8
0
 public override void WriteTo(Stream writer)
 {
     byte[] address = Address.GetAddressBytes();
     BinaryHelper.Write(writer, (ushort)address.Length);
     BinaryHelper.Write(writer, address);
 }
Esempio n. 9
0
 public override void WriteTo(Stream writer)
 {
     BinaryHelper.Write(writer, ((ushort)Encoding.UTF8.GetByteCount(CNAME)));
     BinaryHelper.Write(writer, Encoding.UTF8.GetBytes(CNAME));
 }
Esempio n. 10
0
 public void WriteTo(Stream stream)
 {
     DomainName.WriteTo(stream);
     BinaryHelper.Write(stream, (ushort)Type);
     BinaryHelper.Write(stream, (ushort)Class);
 }