In addition, it fails to properly respond for <hostname>.local queries.
Code (from tve):
Code: Select all
static bool mdns_started = false;
static struct mdns_info mdns_info;
static ICACHE_FLASH_ATTR
void wifiStartMDNS(struct ip_addr ip) {
if (!mdns_started) {
os_memset(&mdns_info, 0, sizeof(struct mdns_info));
mdns_info.host_name = flashConfig.hostname;
mdns_info.server_name = "http"; // service name
mdns_info.server_port = 80; // service port
mdns_info.ipAddr = ip.addr;
espconn_mdns_init(&mdns_info);
mdns_started = true;
}
}
wifiStartMDNS is called after the Wifi connection is stable, ESP is running in STATION mode.
Wireshark show the following advertisment:
Code: Select all
No. Time Source Destination Protocol Length Info
107234 2015-11-26 09:55:20.922948000 192.168.254.82 224.0.0.251 MDNS 219 Standard query response 0x0000 PTR ems-link02._http._tcp.local TXT, cache flush SRV, cache flush 0 0 80 ems-link02.local A, cache flush 192.168.254.82
Frame 107234: 219 bytes on wire (1752 bits), 219 bytes captured (1752 bits) on interface 0
Interface id: 0
Encapsulation type: Linux cooked-mode capture (25)
Arrival Time: Nov 26, 2015 09:55:20.922948000 CET
[Time shift for this packet: 0.000000000 seconds]
Epoch Time: 1448528120.922948000 seconds
[Time delta from previous captured frame: 0.045418000 seconds]
[Time delta from previous displayed frame: 0.045418000 seconds]
[Time since reference or first frame: 2327.739204000 seconds]
Frame Number: 107234
Frame Length: 219 bytes (1752 bits)
Capture Length: 219 bytes (1752 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: sll:ip:udp:dns]
[Coloring Rule Name: ems-link02]
[Coloring Rule String: ip.addr==192.168.254.82]
Linux cooked capture
Packet type: Multicast (2)
Link-layer address type: 1
Link-layer address length: 6
Source: Espressi_f3:bf:0f (18:fe:34:f3:bf:0f)
Protocol: IP (0x0800)
Internet Protocol Version 4, Src: 192.168.254.82 (192.168.254.82), Dst: 224.0.0.251 (224.0.0.251)
Version: 4
Header length: 20 bytes
Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00: Not-ECT (Not ECN-Capable Transport))
0000 00.. = Differentiated Services Codepoint: Default (0x00)
.... ..00 = Explicit Congestion Notification: Not-ECT (Not ECN-Capable Transport) (0x00)
Total Length: 203
Identification: 0x0012 (18)
Flags: 0x00
0... .... = Reserved bit: Not set
.0.. .... = Don't fragment: Not set
..0. .... = More fragments: Not set
Fragment offset: 0
Time to live: 255
Protocol: UDP (17)
Header checksum: 0x1b19 [validation disabled]
[Good: False]
[Bad: False]
Source: 192.168.254.82 (192.168.254.82)
Destination: 224.0.0.251 (224.0.0.251)
[Source GeoIP: Unknown]
[Destination GeoIP: Unknown]
User Datagram Protocol, Src Port: mdns (5353), Dst Port: mdns (5353)
Source port: mdns (5353)
Destination port: mdns (5353)
Length: 183
Checksum: 0x65b5 [validation disabled]
[Good Checksum: False]
[Bad Checksum: False]
Domain Name System (response)
Transaction ID: 0x0000
Flags: 0x8400 Standard query response, No error
1... .... .... .... = Response: Message is a response
.000 0... .... .... = Opcode: Standard query (0)
.... .1.. .... .... = Authoritative: Server is an authority for domain
.... ..0. .... .... = Truncated: Message is not truncated
.... ...0 .... .... = Recursion desired: Don't do query recursively
.... .... 0... .... = Recursion available: Server can't do recursive queries
.... .... .0.. .... = Z: reserved (0)
.... .... ..0. .... = Answer authenticated: Answer/authority portion was not authenticated by the server
.... .... ...0 .... = Non-authenticated data: Unacceptable
.... .... .... 0000 = Reply code: No error (0)
Questions: 0
Answer RRs: 4
Authority RRs: 0
Additional RRs: 0
Answers
_http._tcp.local: type PTR, class IN, ems-link02._http._tcp.local
Name: _http._tcp.local
Type: PTR (Domain name pointer)
.000 0000 0000 0001 = Class: IN (0x0001)
0... .... .... .... = Cache flush: False
Time to live: 5 minutes
Data length: 13
Domain Name: ems-link02._http._tcp.local
ems-link02._http._tcp.local: type TXT, class IN, cache flush
Name: ems-link02._http._tcp.local
Type: TXT (Text strings)
.000 0000 0000 0001 = Class: IN (0x0001)
1... .... .... .... = Cache flush: True
Time to live: 5 minutes
Data length: 19
TXT Length: 18
TXT: vendor = Espressif
ems-link02._http._tcp.local: type SRV, class IN, cache flush, priority 0, weight 0, port 80, target ems-link02.local
Service: ems-link02
Protocol: _http
Name: _tcp.local
Type: SRV (Service location)
.000 0000 0000 0001 = Class: IN (0x0001)
1... .... .... .... = Cache flush: True
Time to live: 5 minutes
Data length: 24
Priority: 0
Weight: 0
Port: 80
Target: ems-link02.local
ems-link02.local: type A, class IN, cache flush, addr 192.168.254.82
Name: ems-link02.local
Type: A (Host address)
.000 0000 0000 0001 = Class: IN (0x0001)
1... .... .... .... = Cache flush: True
Time to live: 5 minutes
Data length: 4
Addr: 192.168.254.82 (192.168.254.82)
Imho, the response has multiple errors:
a) _http._tcp.local (the service_name) is an ambiguous RR, because it's missing the hostname
b) the PTR doesn't refer to an resolvable RR (neither PTR nor A record for ems-link02._http._tcp.local)
c) the PTR should refer to ems-link02.local
When trying to query for "ems-link02.local" the device doesn't respond at all. Instead, when querying for "_http._tcp.local" it responds with the wrong query result. So it looks like the query is only compared against the (wrong) PTR record, but not against the A record.
As sidenote, it would be really nice to have some additional mDNS API to add a service name or remove a service name.