NetworkPackets.Dns.Question.Question C# (CSharp) Method

Question() public method

Constructor when creating a Dns Query
public Question ( String QName, DnsPacket QType, DnsPacket QClass ) : Brunet
QName String the name of resource you are looking up, IP Address when QType = Ptr otherwise hostname
QType DnsPacket the type of look up to perform
QClass DnsPacket should always be IN
return Brunet
    public Question(String QName, DnsPacket.Types QType, DnsPacket.Classes QClass) {
      this.QName = QName;
      this.QType = QType;
      this.QClass = QClass;

      if(QType == DnsPacket.Types.A || QType == DnsPacket.Types.AAAA) {
        QNameBlob = DnsPacket.HostnameStringToMemBlock(QName);
      }
      else if(QType == DnsPacket.Types.Ptr) {
        QNameBlob = DnsPacket.PtrStringToMemBlock(QName);
      }
      else {
        throw new Exception("Invalid QType: " + QType + "!");
      }

        // 2 for QType + 2 for QClass
      byte[] data = new byte[4];
      int idx = 0;
      data[idx++] = (byte) ((((int) QType) >> 8) & 0xFF);
      data[idx++] = (byte) (((int) QType) & 0xFF);
      data[idx++] = (byte) ((((int) QClass) >> 8) & 0xFF);
      data[idx++] = (byte) (((int) QClass) & 0xFF);
      _icpacket = new CopyList(QNameBlob, MemBlock.Reference(data));
    }

Same methods

Question::Question ( MemBlock Data, int Start ) : Brunet
Question