Added TC for dns request

This commit is contained in:
Ziver Koc 2016-08-10 00:11:02 +02:00
parent e8e3deb056
commit 0774bcd26c
3 changed files with 24 additions and 2 deletions

View file

@ -205,7 +205,27 @@ Domain Name System (query)
Type: A (Host address)
Class: IN (0x0001)
*/
// TODO
DNSPacket packet = new DNSPacket();
DNSPacketHeader header = packet.getHeader();
header.id = 0x241a;
header.flagRecursionDesired = true;
header.countQuestion = 1;
DNSPacketQuestion question = new DNSPacketQuestion();
question.qName = "www.google.com";
question.qType = QTYPE_A;
question.qClass = QCLASS_IN;
packet.addQuestion(question);
ByteArrayOutputStream buff = new ByteArrayOutputStream();
BinaryStructOutputStream out = new BinaryStructOutputStream(buff);
packet.write(out);
byte[] data = buff.toByteArray();
assertEquals((
"241a 01 00 00 01 00 00 00 00 00 00 " +
"03 77 77 77 06 67 6f 6f 67 6c 65 03 63 6f 6d 00 0001 0001"
).replace(" ",""),
Converter.toHexString(data));
}
@Test

View file

@ -13,6 +13,7 @@ public class MulticastDNSClientTest {
MulticastDNSClient mdns = new MulticastDNSClient();
mdns.start();
//mdns.sendProbe("appletv.local");
mdns.sendProbe("_services._dns-sd._udp.local");
//mdns.sendProbe("_services._dns-sd._udp.local");
mdns.sendProbe("_googlecast._tcp.local");
}
}