Ejemplo n.º 1
0
        /// <summary>
        /// Parses resource record from reply data.
        /// </summary>
        /// <param name="name">DNS domain name that owns a resource record.</param>
        /// <param name="reply">DNS server reply data.</param>
        /// <param name="offset">Current offset in reply data.</param>
        /// <param name="rdLength">Resource record data length.</param>
        /// <param name="ttl">Time to live in seconds.</param>
        public static DnsRecord_HINFO Parse(string name, byte[] reply, ref int offset, int rdLength, int ttl)
        {
            /* RFC 1035 3.3.2. HINFO RDATA format
             *
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             *          /                      CPU                      /
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             *          /                       OS                      /
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             *
             *          CPU     A <character-string> which specifies the CPU type.
             *
             *          OS      A <character-string> which specifies the operating
             *                          system type.
             *
             *                          Standard values for CPU and OS can be found in [RFC-1010].
             *
             */

            // CPU
            string cpu = DnsTool.ReadCharacterString(reply, ref offset);

            // OS
            string os = DnsTool.ReadCharacterString(reply, ref offset);

            return(new DnsRecord_HINFO(name, cpu, os, ttl));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Parses resource record from reply data.
        /// </summary>
        /// <param name="name">DNS domain name that owns a resource record.</param>
        /// <param name="reply">DNS server reply data.</param>
        /// <param name="offset">Current offset in reply data.</param>
        /// <param name="rdLength">Resource record data length.</param>
        /// <param name="ttl">Time to live in seconds.</param>
        public static DnsRecord_SPF Parse(string name, byte[] reply, ref int offset, int rdLength, int ttl)
        {
            // SPF RR

            string text = DnsTool.ReadCharacterString(reply, ref offset);

            return(new DnsRecord_SPF(name, text, ttl));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Parses resource record from reply data.
        /// </summary>
        /// <param name="name">DNS domain name that owns a resource record.</param>
        /// <param name="reply">DNS server reply data.</param>
        /// <param name="offset">Current offset in reply data.</param>
        /// <param name="rdLength">Resource record data length.</param>
        /// <param name="ttl">Time to live in seconds.</param>
        public static DnsRecord_NAPTR Parse(string name, byte[] reply, ref int offset, int rdLength, int ttl)
        {
            /* RFC 3403.
             *  The packet format for the NAPTR record is as follows
             *                                 1  1  1  1  1  1
             *   0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |                     ORDER                     |
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |                   PREFERENCE                  |
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |  /                     FLAGS                     /
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |  /                   SERVICES                    /
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |  /                    REGEXP                     /
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |  /                  REPLACEMENT                  /
             |  /                                               /
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             */

            int order = reply[offset++] << 8 | reply[offset++];

            int preference = reply[offset++] << 8 | reply[offset++];

            string flags = DnsTool.ReadCharacterString(reply, ref offset);

            string services = DnsTool.ReadCharacterString(reply, ref offset);

            string regexp = DnsTool.ReadCharacterString(reply, ref offset);

            string replacement = "";

            DnsTool.GetQName(reply, ref offset, ref replacement);

            return(new DnsRecord_NAPTR(name, order, preference, flags, services, regexp, replacement, ttl));
        }