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));
}