Example #1
0
        private byte[] data;                // Resource record data

        /// <summary>
        /// This constructor initializes an empty DNS resource
        /// record.
        /// </summary>
        public DnsRR()
        {
            this.rrtype = DnsRRType.UNKNOWN;
            this.rname  = string.Empty;
            this.qclass = DnsQClass.IN;
            this.ttl    = 0;
            this.data   = new byte[0];
        }
Example #2
0
        /// <summary>
        /// This method parses the resource record 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 record is located.
        /// This parameter will return set to the offset of the first
        /// byte after the parsed record.
        /// </param>
        /// <returns>True on success.</returns>
        public bool Read(DnsMessage message, byte[] packet, ref int offset)
        {
            if (!message.ReadName(packet, ref offset, out rname))
            {
                return(false);
            }

            rrtype = (DnsRRType)Helper.ReadInt16(packet, ref offset);
            qclass = (DnsQClass)Helper.ReadInt16(packet, ref offset);
            ttl    = Helper.ReadInt32(packet, ref offset);

            return(ReadData(message, packet, ref offset));
        }
Example #3
0
 /// <summary>
 /// Returns <c>true</c> if the resource records type and qname
 /// match the parameters passed.
 /// </summary>
 /// <param name="rrType">The resource type to be matched.</param>
 /// <param name="qname">The qname to be matched.</param>
 /// <returns><c>true</c> if there's a match.</returns>
 public bool Match(DnsRRType rrType, string qname)
 {
     return(this.RRType == rrType && String.Compare(this.RName, qname, true) == 0);
 }