khoih-prog / MDNS_Generic

mDNS Library for nRF52, SAMD21, SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, AVR Mega, RP2040-based boards, etc. using Ethernet W5x00. Supports mDNS (Registering Services) and DNS-SD (Service Discovery). Ethernet_Generic library is used as default for W5x00
GNU General Public License v3.0
38 stars 12 forks source link

Check on UDP length maybe discards correct responses #10

Closed FStefanni closed 2 years ago

FStefanni commented 2 years ago

Describe the bug

Hi,

I have this setup:

On all of tem MDNS is configured (on Esp32, I am using the example sketch WiFiResolvingHostNames)

After some debug, I have found this check in the lib code (near line 963 of file MDNS_Generic_Impl.h):

//KH, to report name Resolve only UDP packet has corect size of 48
if (48 == udp_len)

So I put a debug print, and actually what I got is:

So the question/bug is:

Please note that on Rasberry and Linux no acutal services discoverable via MDNS are running: what I need is to just resolve the ip.

Regards

Steps to Reproduce

I am using the WiFiResolvingHostNames sketch.

Expected behavior

I was expecting to be able to resolve the ip.

Actual behavior

The sketch prints Resolving XXX error

Information

khoih-prog commented 2 years ago

Hi @FStefanni

Thanks for your usage of the library and the issue report.

As you're using ESP32, I suggest that you use the native ESP32-core ESPmDNS library

If you still have issue, please post on the ESP32 core issue, with the Minimal, Reproducible Example so that other people can duplicate the issue and help.

I'm sorry I don't have time to spend here as the library is mainly designed for boards besides ESP32/ESP8266, and I'm trying to offload any issue to other cores / libraries if possible.

I certainly reopen, spend some time to investigate and fix the library if you can prove clearly this is a bug of the library.

Thanks again and Good Luck,

khoih-prog commented 2 years ago

Hereafter is the debug terminal showing the correct UDP packet size 48 received and processed

[MDNS] Receiving len =  14 , hostname raspberrypi-02
Resolving 'raspberrypi-02' via Multicast DNS (Bonjour)...
[MDNS] ::resolveName: name= raspberrypi-02.local
[MDNS] ::_sendMDNSMessage: xid= 0
[MDNS] ::_sendMDNSMessage: queryCount= 256
[MDNS] ::_sendMDNSMessage: answerCount= 0
[MDNS] ::_sendMDNSMessage: authorityCount= 0
[MDNS] ::_sendMDNSMessage: additionalCount= 0
[MDNS] ::_sendMDNSMessage: statusCode = 1
[MDNS] ::_processMDNSQuery: UDP parsePacket len= 48
[MDNS] ::_processMDNSQuery: UDP parsePacket len= 48
[MDNS] buffer======
0, 0, 84, 0, 0, 0, 0, 1, 0, 0, 0, 0, e, 72, 61, 73, 70, 62, 65, 72, 
72, 79, 70, 69, 2d, 30, 32, 5, 6c, 6f, 63, 61, 6c, 0, 0, 1, 80, 1, 0, 0, 
0, 78, 0, 4, c0, a8, 2, 70, 
[MDNS] =====
[MDNS] ::_processMDNSQuery: to report IP, buf = 192
[MDNS] ::_finishedResolvingName: name = raspberrypi-02 , IP = 192.168.2.112
The IP address for 'raspberrypi-02' is 192.168.2.112
[MDNS] IP[ 0 ]= 192
[MDNS] IP[ 1 ]= 168
[MDNS] IP[ 2 ]= 2
[MDNS] IP[ 3 ]= 112
[MDNS] ::_processMDNSQuery: UDP parsePacket len= 48
[MDNS] ::_processMDNSQuery: UDP parsePacket len= 48
[MDNS] buffer======
0, 0, 84, 0, 0, 0, 0, 1, 0, 0, 0, 0, e, 72, 61, 73, 70, 62, 65, 72, 
72, 79, 70, 69, 2d, 30, 32, 5, 6c, 6f, 63, 61, 6c, 0, 0, 1, 80, 1, 0, 0, 
0, 78, 0, 4, c0, a8, 2, 7a, 
FStefanni commented 2 years ago

Hi,

thank you for the reply. So my doubt is: is it really correct to check only for a length of 48? Why am I receiving a length of 40?

Nevertheless, I am going to check the ESPmDNS library library.

Regards

[EDIT] FYI, ESPmDNS library works fine. Thank you for the suggestion.