Exemple #1
0
        public Tuple <MemoryStream, DNSOutputStream> DNSOutput()
        {
            var compress = new CompressionOutputContext();
            var memory   = new MemoryStream();
            var stream   = new DNSOutputStream(memory, compress);

            return(Tuple.Create(memory, stream));
        }
Exemple #2
0
        /**
         * A convenience wrapper around Serialize.
         */
        public byte[] ToBytes()
        {
            var buffer_stream = new MemoryStream();
            var compress      = new CompressionOutputContext();
            var dns_out       = new DNSOutputStream(buffer_stream, compress);

            Serialize(dns_out);
            return(buffer_stream.ToArray());
        }
 public void Serialize(DNSOutputStream stream)
 {
     stream.WriteDomain(PrimaryNameServer);
     stream.WriteDomain(Hostmaster);
     stream.WriteUInt32(Serial);
     stream.WriteUInt32(RefreshSeconds);
     stream.WriteUInt32(RetrySeconds);
     stream.WriteUInt32(ExpireSeconds);
     stream.WriteUInt32(MinimumTTL);
 }
Exemple #4
0
        /**
         * Converts a record object into the raw bytes that represent
         * it on the wire.
         */
        public void Serialize(DNSOutputStream stream)
        {
            stream.WriteDomain(Name);
            stream.WriteUInt16((UInt16)Resource.Type);
            stream.WriteUInt16((UInt16)AddressClass);
            stream.WriteUInt32(TimeToLive);

            var length_hole = stream.WriteUInt16Hole();
            var start_posn  = stream.Position;

            Resource.Serialize(stream);
            var end_posn = stream.Position;

            length_hole.Fill((UInt16)(end_posn - start_posn));
        }
Exemple #5
0
        public void Serialize(DNSOutputStream stream)
        {
            stream.WriteUInt16(Id);

            var fields = new FieldGroup()
                         .Add(new Field(1, IsQuery ? (byte)0 : (byte)1))
                         .Add(new Field(4, (byte)QueryType))
                         .Add(new Field(1, IsAuthority ? (byte)1 : (byte)0))
                         .Add(new Field(1, IsTruncated ? (byte)1 : (byte)0))
                         .Add(new Field(1, RecursiveRequest ? (byte)1 : (byte)0));

            stream.WriteByte(fields.Pack());

            fields = new FieldGroup()
                     .Add(new Field(1, RecursiveResponse ? (byte)1 : (byte)0))
                     .Add(new Field(3, 0))
                     .Add(new Field(4, (byte)ResponseType));
            stream.WriteByte(fields.Pack());

            stream.WriteUInt16((UInt16)Questions.Length);
            stream.WriteUInt16((UInt16)Answers.Length);
            stream.WriteUInt16((UInt16)AuthoritativeAnswers.Length);
            stream.WriteUInt16((UInt16)AdditionalRecords.Length);

            foreach (var question in Questions)
            {
                question.Serialize(stream);
            }

            foreach (var answer in Answers)
            {
                answer.Serialize(stream);
            }

            foreach (var authority in AuthoritativeAnswers)
            {
                authority.Serialize(stream);
            }

            foreach (var additional in AdditionalRecords)
            {
                additional.Serialize(stream);
            }
        }
Exemple #6
0
 public void Serialize(DNSOutputStream stream)
 {
     stream.WriteDomain(Name);
     stream.WriteUInt16((UInt16)raw_query_type);
     stream.WriteUInt16((UInt16)raw_address_class);
 }
 public void Serialize(DNSOutputStream stream)
 {
     stream.WriteIPv4Address(Address);
 }
 public void Serialize(DNSOutputStream stream)
 {
     stream.WriteDomain(Pointer);
 }
 public void Serialize(DNSOutputStream stream)
 {
     stream.WriteUInt16(Preference);
     stream.WriteDomain(Mailserver);
 }
 public void Serialize(DNSOutputStream stream)
 {
     stream.WriteDomain(Alias);
 }
 public void Serialize(DNSOutputStream stream)
 {
     stream.WriteDomain(Nameserver);
 }