Beispiel #1
0
        /// <summary>
        /// Creates a new instance of this class by parsing the given data
        /// </summary>
        /// <param name="bData">The data to parse</param>
        public DNSFrame(byte[] bData)
        {
            sIdentifier      = (short)((bData[0] << 8) + bData[1]);
            bQRFlag          = (bData[2] & 0x80) > 0;
            dnsOperationCode = (DNSOptCode)((bData[2] >> 3) & 0x0F);
            bAAFlag          = (bData[2] & 0x04) > 0;
            bTCFlag          = (bData[2] & 0x02) > 0;
            bRDFlag          = (bData[2] & 0x01) > 0;
            bRAFlag          = (bData[3] & 0x80) > 0;
            dnsResponseCode  = (DNSResponseCode)((bData[3]) & 0x0F);

            int iQCount    = (bData[4] << 8) + bData[5];
            int iACount    = (bData[6] << 8) + bData[7];
            int iAuthCount = (bData[8] << 8) + bData[9];
            int iAddCount  = (bData[10] << 8) + bData[11];

            lQuestions   = new List <DNSQuestion>();
            lAnswers     = new List <DNSResourceRecord>();
            lAuthorotive = new List <DNSResourceRecord>();
            lAdditional  = new List <DNSResourceRecord>();

            int iIndex = 12;

            while (lQuestions.Count < iQCount)
            {
                DNSQuestion qLast = new DNSQuestion(bData, ref iIndex);
                lQuestions.Add(qLast);
            }
            while (lAnswers.Count < iACount)
            {
                DNSResourceRecord rLast = new DNSResourceRecord(bData, ref iIndex);
                lAnswers.Add(rLast);
            }
            while (lAuthorotive.Count < iAuthCount)
            {
                DNSResourceRecord rLast = new DNSResourceRecord(bData, ref iIndex);
                lAuthorotive.Add(rLast);
            }
            while (lAdditional.Count < iAddCount)
            {
                DNSResourceRecord rLast = new DNSResourceRecord(bData, ref iIndex);
                lAdditional.Add(rLast);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Removes a question record from this instance
 /// </summary>
 /// <param name="item">The record to remove</param>
 public void RemoveQuestion(DNSQuestion item)
 {
     lQuestions.Remove(item);
 }
Beispiel #3
0
 /// <summary>
 /// Checks whether a specific question record is contained in this instance
 /// </summary>
 /// <param name="item">The question record to search for</param>
 /// <returns>A bool indication whether a specific question record is contained in this instance</returns>
 public bool ContainsQuestion(DNSQuestion item)
 {
     return(lQuestions.Contains(item));
 }
Beispiel #4
0
 /// <summary>
 /// Adds a question record to this instance
 /// </summary>
 /// <param name="item">The question record to add</param>
 public void AddQuestion(DNSQuestion item)
 {
     lQuestions.Add(item);
 }