Exemple #1
0
        /// <summary>
        /// Writes the RDATA of this resource record to the specified
        /// <see cref="AK.Net.Dns.IDnsWriter"/>.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <exception cref="System.ArgumentNullException">
        /// Thrown when <paramref name="writer"/> <see langword="null"/>.
        /// </exception>
        public override void WriteData(IDnsWriter writer)
        {
            Guard.NotNull(writer, "writer");

            writer.WriteUInt16(this.Priority);
            writer.WriteUInt16(this.Weight);
            writer.WriteUInt16(this.Port);
            writer.WriteName(this.Target);
        }
Exemple #2
0
        /// <summary>
        /// Formats and writes this header to the specified query writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <exception cref="System.ArgumentNullException">
        /// Thrown when <paramref name="writer"/> is <see langword="null"/>.
        /// </exception>
        public virtual void Write(IDnsWriter writer)
        {
            Guard.NotNull(writer, "writer");

            writer.WriteUInt16((ushort)this.Id);

            byte b3 = 0;

            if (!this.IsQuery)
            {
                b3 |= 0x80;
            }
            b3 |= (byte)(((byte)this.OpCode & 0x0F) << 3);
            if (this.IsAuthorative)
            {
                b3 |= 0x04;
            }
            if (this.IsTruncated)
            {
                b3 |= 0x02;
            }
            if (this.IsRecursionDesired)
            {
                b3 |= 0x01;
            }
            writer.WriteByte(b3);

            byte b4 = (byte)this.ResponseCode;

            if (this.IsRecursionAllowed)
            {
                b4 |= 0x80;
            }
            writer.WriteByte(b4);

            writer.WriteUInt16(this.QuestionCount);
            writer.WriteUInt16(this.AnswerCount);
            writer.WriteUInt16(this.AuthorityCount);
            writer.WriteUInt16(this.AdditionalCount);
        }