Example #1
0
        /// <summary>
        /// Create a new DNS request.
        /// </summary>
        /// <param name="id">A 16 bit identifier assigned by the program that generates any kind of query.</param>
        /// <param name="rd">Recursion Desired - If RD is set, it directs the name server to pursue the query recursively.</param>
        /// <param name="opcode">A four bit field that specifies kind of query in this message.</param>
        /// <param name="question"></param>
        public Request(ushort id, bool rd, DNS.OPCODE opcode, DNS.Question question)
        {
            if (Object.ReferenceEquals(null, question))
            {
                throw new ArgumentNullException("question");
            }

            Header.ID     = id;
            Header.QR     = DNS.QR.Q;
            Header.RD     = rd;
            Header.OPCODE = opcode;
            Questions.Add(question);
        }
Example #2
0
 public void WriteRequestFlags(DNS.OPCODE opcode, bool rd)
 {
     // only OPCODE and RD may be non-zero
     WriteUInt16((ushort)((((int)opcode & 0xF) << 11) | ((rd ? 1 : 0) << 8)));
 }