Beispiel #1
0
        /// <summary>
        /// This method parses the resource record's (including its
        /// length from the packet beginning at the offset passed.
        /// </summary>
        /// <param name="message">The message containing the record being parsed.</param>
        /// <param name="packet">The packet buffer.</param>
        /// <param name="offset">
        /// The offset in the packet where the data will be read.
        /// This parameter will return set to the offset of the first
        /// byte after the parsed data.
        /// </param>
        /// <returns>True on success.</returns>
        protected override bool ReadData(DnsMessage message, byte[] packet, ref int offset)
        {
            byte[] buf;
            int    pos;
            int    cb;

            cb  = Helper.ReadInt16(packet, ref offset);
            pos = offset;
            if (cb != 4)
            {
                return(false);
            }

            buf = new byte[4];
            for (int i = 0; i < 4; i++)
            {
                buf[i] = packet[offset++];
            }

            ipAddr = new IPAddress(buf);

            return(pos + cb == offset);
        }
Beispiel #2
0
 /// <summary>
 /// This method parses the resource record's (including its
 /// length from the packet beginning at the offset passed.
 /// </summary>
 /// <param name="message">The message containing the record being parsed.</param>
 /// <param name="packet">The packet buffer.</param>
 /// <param name="offset">
 /// The offset in the packet where the data will be read.
 /// This parameter will return set to the offset of the first
 /// byte after the parsed data.
 /// </param>
 /// <returns>True on success.</returns>
 protected override bool ReadData(DnsMessage message, byte[] packet, ref int offset)
 {
     Assertion.Test(false, "NAK's should never be sent in DNS messages.");
     return(false);
 }
Beispiel #3
0
 /// <summary>
 /// This method writes the resource record's data (including its
 /// length to the packet beginning at the offset passed.
 /// </summary>
 /// <param name="message">The DNS message being serialized.</param>
 /// <param name="packet">The packet buffer.</param>
 /// <param name="offset">
 /// The offset in the packet where the data will be written.
 /// This parameter will return set to the offset of the first
 /// byte after the written data.
 /// </param>
 protected override void WriteData(DnsMessage message, byte[] packet, ref int offset)
 {
     Assertion.Test(false, "NAK's should never be sent in DNS messages.");
 }
Beispiel #4
0
 /// <summary>
 /// This method parses the resource record's (including its
 /// length from the packet beginning at the offset passed.
 /// </summary>
 /// <param name="message">The message containing the record being parsed.</param>
 /// <param name="packet">The packet buffer.</param>
 /// <param name="offset">
 /// The offset in the packet where the data will be read.
 /// This parameter will return set to the offset of the first
 /// byte after the parsed data.
 /// </param>
 /// <returns>True on success.</returns>
 protected virtual bool ReadData(DnsMessage message, byte[] packet, ref int offset)
 {
     data = Helper.ReadBytes16(packet, ref offset);
     return(true);
 }
Beispiel #5
0
 /// <summary>
 /// This method writes the resource record's data (including its
 /// length to the packet beginning at the offset passed.
 /// </summary>
 /// <param name="message">The DNS message being serialized.</param>
 /// <param name="packet">The packet buffer.</param>
 /// <param name="offset">
 /// The offset in the packet where the data will be written.
 /// This parameter will return set to the offset of the first
 /// byte after the written data.
 /// </param>
 protected virtual void WriteData(DnsMessage message, byte[] packet, ref int offset)
 {
     Helper.WriteBytes16(packet, ref offset, data);
 }
Beispiel #6
0
 /// <summary>
 /// Compares the query type and qname of this message to the one
 /// passed.
 /// </summary>
 /// <param name="message">The message to be compared.</param>
 /// <returns><c>true</c> if the query type and qnames match.</returns>
 public bool Match(DnsMessage message)
 {
     return(this.QType == message.QType && String.Compare(this.QName, message.QName, true) == 0);
 }