| Index: pkg/mdns/test/decode_test.dart
|
| diff --git a/pkg/mdns/test/decode_test.dart b/pkg/mdns/test/decode_test.dart
|
| index b17fddcfeb87b9a309f80ba47002137af052c4f0..1f7a913d074260c565b0fb4561c2757bf571bd0e 100644
|
| --- a/pkg/mdns/test/decode_test.dart
|
| +++ b/pkg/mdns/test/decode_test.dart
|
| @@ -25,9 +25,29 @@ testValidPackages() {
|
| Expect.equals('raspberrypi.local', result[1].name);
|
| Expect.equals('169.254.95.83', result[1].address.address);
|
|
|
| - // This packet has no IPv4 address.
|
| result = decodeMDnsResponse(package3);
|
| - Expect.equals(0, result.length);
|
| + Expect.equals(8, result.length);
|
| + Expect.equals("""
|
| +RR 16 [0]
|
| +RR 12 raspberrypi._udisks-ssh._tcp.local
|
| +RR 33 raspberrypi.local
|
| +RR 16 [0]
|
| +RR 12 _udisks-ssh._tcp.local
|
| +RR 12 raspberrypi [b8:27:eb:03:92:4b]._workstation._tcp.local
|
| +RR 33 raspberrypi.local
|
| +RR 12 _workstation._tcp.local""",
|
| + result.join('\n'));
|
| +
|
| + result = decodeMDnsResponse(packagePtrResponse);
|
| + Expect.equals(6, result.length);
|
| + Expect.equals("""
|
| +RR 12 fletch-agent on raspberrypi._fletch_agent._tcp.local
|
| +RR 16 [0]
|
| +RR 33 raspberrypi.local
|
| +RR 28 [254, 128, 0, 0, 0, 0, 0, 0, 186, 39, 235, 255, 254, 105, 110, 58]
|
| +RR 1 InternetAddress('192.168.1.1', IP_V4)
|
| +RR 1 InternetAddress('169.254.167.172', IP_V4)""",
|
| + result.join('\n'));
|
| }
|
|
|
| testBadPackages() {
|
| @@ -40,6 +60,7 @@ testBadPackages() {
|
|
|
| testHexDumpList() {
|
| // Call hexDumpList to get rid of hint.
|
| + formatHexStream("");
|
| hexDumpList([]);
|
| }
|
|
|
| @@ -63,7 +84,7 @@ var package2 = [
|
| 0x01, 0x80, 0x01, 0x00, 0x00, 0x00, 0x78, 0x00,
|
| 0x04, 0xa9, 0xfe, 0x5f, 0x53];
|
|
|
| -// Seven mixed answers.
|
| +// Eight mixed answers.
|
| var package3 = [
|
| 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x08,
|
| 0x00, 0x00, 0x00, 0x00, 0x1f, 0x72, 0x61, 0x73,
|
| @@ -97,6 +118,50 @@ var package3 = [
|
| 0xc0, 0x88, 0xc0, 0xa3, 0x00, 0x0c, 0x00, 0x01,
|
| 0x00, 0x00, 0x11, 0x94, 0x00, 0x02, 0xc0, 0x2c];
|
|
|
| +var packagePtrResponse = <int>[
|
| + 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x06,
|
| + 0x00, 0x00, 0x00, 0x00, 0x0d, 0x5f, 0x66, 0x6c,
|
| + 0x65, 0x74, 0x63, 0x68, 0x5f, 0x61, 0x67, 0x65,
|
| + 0x6e, 0x74, 0x04, 0x5f, 0x74, 0x63, 0x70, 0x05,
|
| + 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, 0x00, 0x0c,
|
| + 0x00, 0x01, 0x00, 0x00, 0x11, 0x94, 0x00, 0x1e,
|
| + 0x1b, 0x66, 0x6c, 0x65, 0x74, 0x63, 0x68, 0x2d,
|
| + 0x61, 0x67, 0x65, 0x6e, 0x74, 0x20, 0x6f, 0x6e,
|
| + 0x20, 0x72, 0x61, 0x73, 0x70, 0x62, 0x65, 0x72,
|
| + 0x72, 0x79, 0x70, 0x69, 0xc0, 0x0c, 0xc0, 0x30,
|
| + 0x00, 0x10, 0x80, 0x01, 0x00, 0x00, 0x11, 0x94,
|
| + 0x00, 0x01, 0x00, 0xc0, 0x30, 0x00, 0x21, 0x80,
|
| + 0x01, 0x00, 0x00, 0x00, 0x78, 0x00, 0x14, 0x00,
|
| + 0x00, 0x00, 0x00, 0x2f, 0x59, 0x0b, 0x72, 0x61,
|
| + 0x73, 0x70, 0x62, 0x65, 0x72, 0x72, 0x79, 0x70,
|
| + 0x69, 0xc0, 0x1f, 0xc0, 0x6d, 0x00, 0x1c, 0x80,
|
| + 0x01, 0x00, 0x00, 0x00, 0x78, 0x00, 0x10, 0xfe,
|
| + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xba,
|
| + 0x27, 0xeb, 0xff, 0xfe, 0x69, 0x6e, 0x3a, 0xc0,
|
| + 0x6d, 0x00, 0x01, 0x80, 0x01, 0x00, 0x00, 0x00,
|
| + 0x78, 0x00, 0x04, 0xc0, 0xa8, 0x01, 0x01, 0xc0,
|
| + 0x6d, 0x00, 0x01, 0x80, 0x01, 0x00, 0x00, 0x00,
|
| + 0x78, 0x00, 0x04, 0xa9, 0xfe, 0xa7, 0xac
|
| +];
|
| +
|
| +// Support code to generate the hex-lists above from
|
| +// a hex-stream.
|
| +void formatHexStream(String hexStream) {
|
| + var s = '';
|
| + for (int i = 0; i < hexStream.length / 2; i++) {
|
| + if (s.length != 0) s += ', ';
|
| + s += '0x';
|
| + var x = hexStream.substring(i * 2, i * 2 + 2);
|
| + s += x;
|
| + if (((i + 1) % 8) == 0) {
|
| + s += ',';
|
| + print(s);
|
| + s = '';
|
| + }
|
| + }
|
| + if (s.length != 0) print(s);
|
| +}
|
| +
|
| // Support code for generating the hex-lists above.
|
| void hexDumpList(List package) {
|
| var s = '';
|
|
|