Example #1
0
        /// <summary>
        /// Create DNS question message for A IN records (as bytes).
        /// </summary>
        public static byte[] CreateQuestionAsBytes(string name, string qtype)
        {
            var message = new DnsMessage();
            var header  = new DnsHeader();

            header.ID      = GetId();
            header.QDCOUNT = 1;
            message.Header = header;

            var question = new DnsQuestion();

            question.Name    = name;
            question.QType   = (ushort)Enum.Parse(typeof(RecordType), qtype, ignoreCase: true);
            question.QClass  = 1;
            message.Question = question;

            return(DnsMessageToBytes(message));
        }