Exemple #1
0
        public void Serialize(BinaryWriter writer)
        {
            writer.Write(NetworkHelper.Nthos(ID));
            writer.Write(NetworkHelper.Nthos((ushort)Flags));
            writer.Write(NetworkHelper.Nthos(QuestionCount));
            writer.Write(NetworkHelper.Nthos(AnswerCount));
            writer.Write(NetworkHelper.Nthos(AuthoritativeCount));
            writer.Write(NetworkHelper.Nthos(AdditionalCount));

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

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

            foreach (var authoritative in Authoritatives)
            {
                authoritative.Serialize(writer);
            }

            foreach (var additional in Additionals)
            {
                additional.Serialize(writer);
            }
        }
Exemple #2
0
        public void Deserialize(BinaryReader reader)
        {
            ID    = NetworkHelper.Nthos(reader.ReadUInt16());
            Flags = (DnsPacketFlags)NetworkHelper.Nthos(reader.ReadUInt16());
            ushort questionCount      = NetworkHelper.Nthos(reader.ReadUInt16());
            ushort answerCount        = NetworkHelper.Nthos(reader.ReadUInt16());
            ushort authoritativeCount = NetworkHelper.Nthos(reader.ReadUInt16());
            ushort additionalCount    = NetworkHelper.Nthos(reader.ReadUInt16());

            for (int i = 0; i < questionCount; i++)
            {
                DnsQuestion question = new DnsQuestion();
                question.Deserialize(reader);
                Questions.Add(question);
            }

            for (int i = 0; i < answerCount; i++)
            {
                DnsResourceRecord record = DnsResourceRecord.DeserializeResourceRecord(reader);
                Answers.Add(record);
            }

            for (int i = 0; i < authoritativeCount; i++)
            {
                DnsResourceRecord record = DnsResourceRecord.DeserializeResourceRecord(reader);
                Authoritatives.Add(record);
            }

            for (int i = 0; i < additionalCount; i++)
            {
                DnsResourceRecord record = DnsResourceRecord.DeserializeResourceRecord(reader);
                Additionals.Add(record);
            }
        }
Exemple #3
0
        public override void Serialize(BinaryWriter writer)
        {
            base.Serialize(writer);

            writer.Write(NetworkHelper.Nthos(TimeToLive));
            writer.Write(NetworkHelper.Nthos(DataLength));
        }
Exemple #4
0
        public override void Serialize(BinaryWriter writer)
        {
            base.Serialize(writer);

            writer.Write(NetworkHelper.Nthos(Priority));
            writer.Write(NetworkHelper.Nthos(Weight));
            writer.Write(NetworkHelper.Nthos(Port));
            writer.WriteDnsHostname(SrvHostname);
        }
Exemple #5
0
        public override void Deserialize(BinaryReader reader)
        {
            base.Deserialize(reader);

            reader.ReadUInt16();

            Priority    = NetworkHelper.Nthos(reader.ReadUInt16());
            Weight      = NetworkHelper.Nthos(reader.ReadUInt16());
            Port        = NetworkHelper.Nthos(reader.ReadUInt16());
            SrvHostname = reader.ReadDnsHostname();
        }
Exemple #6
0
        public override void Deserialize(BinaryReader reader)
        {
            base.Deserialize(reader);

            TimeToLive = NetworkHelper.Nthos(reader.ReadUInt32());
        }
Exemple #7
0
 public static void ParseDnsRecordHeader(BinaryReader reader, out string hostname, out DnsRecordType type, out DnsRecordClass @class)
 {
     hostname = reader.ReadDnsHostname();
     type     = (DnsRecordType)NetworkHelper.Nthos(reader.ReadUInt16());
     @class   = (DnsRecordClass)NetworkHelper.Nthos(reader.ReadUInt16());
 }
Exemple #8
0
 public virtual void Deserialize(BinaryReader reader)
 {
     Hostname = reader.ReadDnsHostname();
     Type     = (DnsRecordType)NetworkHelper.Nthos(reader.ReadUInt16());
     Class    = (DnsRecordClass)NetworkHelper.Nthos(reader.ReadUInt16());
 }
Exemple #9
0
 public virtual void Serialize(BinaryWriter writer)
 {
     writer.WriteDnsHostname(Hostname);
     writer.Write(NetworkHelper.Nthos((ushort)Type));
     writer.Write(NetworkHelper.Nthos((ushort)Class));
 }