public DnsPacket(short ID, bool Query, byte Opcode, bool AA, bool RA,
bool RD, Question[] Questions, Response[] Answers,
Response[] Authority, Response[] Additional) {
byte[] header = new byte[12];
this.ID = ID;
header[0] = (byte) ((ID >> 8) & 0xFF);
header[1] = (byte) (ID & 0xFF);
this.Query = Query;
if(!Query) {
header[2] |= 0x80;
}
this.Opcode = Opcode;
header[2] |= (byte) (Opcode << 3);
this.AA = AA;
if(AA) {
header[2] |= 0x4;
}
this.RD = RD;
if(RD) {
header[2] |= 0x1;
}
this.RA = RA;
if(RA) {
header[3] |= 0x80;
}
if(Questions != null) {
this.Questions = Questions;
header[4] = (byte) ((Questions.Length >> 8) & 0xFF);
header[5] = (byte) (Questions.Length & 0xFF);
}
else {
this.Questions = new Question[0];
header[4] = 0;
header[5] = 0;
}
if(Answers != null) {
this.Answers = Answers;
header[6] = (byte) ((Answers.Length >> 8) & 0xFF);
header[7] = (byte) (Answers.Length & 0xFF);
}
else {
this.Answers = new Response[0];
header[6] = 0;
header[7] = 0;
}
if(Authority != null) {
this.Authority = Authority;
header[8] = (byte) ((Authority.Length >> 8) & 0xFF);
header[9] = (byte) (Authority.Length & 0xFF);
}
else {
this.Authority = new Response[0];
header[8] = 0;
header[9] = 0;
}
if(Additional != null) {
this.Additional = Additional;
header[10] = (byte) ((Additional.Length >> 8) & 0xFF);
header[11] = (byte) (Additional.Length & 0xFF);
}
else {
this.Additional = new Response[0];
header[10] = 0;
header[11] = 0;
}
_icpacket = MemBlock.Reference(header);
for(int i = 0; i < this.Questions.Length; i++) {
_icpacket = new CopyList(_icpacket, Questions[i].ICPacket);
}
for(int i = 0; i < this.Answers.Length; i++) {
_icpacket = new CopyList(_icpacket, Answers[i].ICPacket);
}
for(int i = 0; i < this.Authority.Length; i++) {
_icpacket = new CopyList(_icpacket, Authority[i].ICPacket);
}
for(int i = 0; i < this.Additional.Length; i++) {
_icpacket = new CopyList(_icpacket, Additional[i].ICPacket);
}
}