示例#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);
            }
        }
示例#2
0
 /// <summary>
 /// Checks whether a specific additional record is contained in this instance
 /// </summary>
 /// <param name="item">The additional record to search for</param>
 /// <returns>A bool indication whether a specific additional record is contained in this instance</returns>
 public bool ContainsAdditional(DNSResourceRecord item)
 {
     return(lAdditional.Contains(item));
 }
示例#3
0
 /// <summary>
 /// Removes a additional record from this instance
 /// </summary>
 /// <param name="item">The record to remove</param>
 public void RemoveAdditional(DNSResourceRecord item)
 {
     lAdditional.Remove(item);
 }
示例#4
0
 /// <summary>
 /// Removes a authorotive record from this instance
 /// </summary>
 /// <param name="item">The record to remove</param>
 public void RemoveAuthorotive(DNSResourceRecord item)
 {
     lAuthorotive.Remove(item);
 }
示例#5
0
 /// <summary>
 /// Adds a additional record to this instance
 /// </summary>
 /// <param name="item">The additional record to add</param>
 public void AddAdditional(DNSResourceRecord item)
 {
     lAdditional.Add(item);
 }
示例#6
0
 /// <summary>
 /// Checks whether a specific authorative record is contained in this instance
 /// </summary>
 /// <param name="item">The authorative record to search for</param>
 /// <returns>A bool indication whether a specific authorative record is contained in this instance</returns>
 public bool ContainsAuthorotive(DNSResourceRecord item)
 {
     return(lAuthorotive.Contains(item));
 }
示例#7
0
 /// <summary>
 /// Adds a authorotive record to this instance
 /// </summary>
 /// <param name="item">The authorotive record to add</param>
 public void AddAuthorotive(DNSResourceRecord item)
 {
     lAuthorotive.Add(item);
 }
示例#8
0
 /// <summary>
 /// Removes a answer record from this instance
 /// </summary>
 /// <param name="item">The record to remove</param>
 public void RemoveAnswer(DNSResourceRecord item)
 {
     lAnswers.Remove(item);
 }
示例#9
0
 /// <summary>
 /// Checks whether a specific answer record is contained in this instance
 /// </summary>
 /// <param name="item">The answer record to search for</param>
 /// <returns>A bool indication whether a specific answer record is contained in this instance</returns>
 public bool ContainsAnswer(DNSResourceRecord item)
 {
     return(lAnswers.Contains(item));
 }
示例#10
0
 /// <summary>
 /// Adds a answer record to this instance
 /// </summary>
 /// <param name="item">The answer record to add</param>
 public void AddAnswer(DNSResourceRecord item)
 {
     lAnswers.Add(item);
 }