Netgear / wsdd2

WSD/LLMNR Discovery/Name Service Daemon
GNU General Public License v3.0
158 stars 34 forks source link

LLMNR does not seem to work #18

Closed marcosfrm closed 3 years ago

marcosfrm commented 4 years ago

wsdd2 does not bind to port 5355? What is port 60180?

# ss -anp | grep wsdd2
u_dgr  UNCONN  0       0                                          * 22095                                                 * 10970                                users:(("wsdd2",pid=781,fd=3))                    
u_str  ESTAB   0       0                                          * 22069                                                 * 22093                                users:(("wsdd2",pid=781,fd=2),("wsdd2",pid=781,fd=1))
udp    UNCONN  0       0                                    0.0.0.0:3702                                            0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=6))                    
udp    UNCONN  0       0                                    0.0.0.0:3702                                            0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=5))                    
udp    UNCONN  0       0                                    0.0.0.0:3702                                            0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=4))                    
udp    UNCONN  0       0                                    0.0.0.0:60180                                           0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=18))                   
udp    UNCONN  0       0                                    0.0.0.0:60180                                           0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=17))                   
udp    UNCONN  0       0                                    0.0.0.0:60180                                           0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=16))                   
udp    UNCONN  0       0                                       [::]:3702                                               [::]:*                                    users:(("wsdd2",pid=781,fd=7))                    
udp    UNCONN  0       0                                       [::]:3702                                               [::]:*                                    users:(("wsdd2",pid=781,fd=8))                    
udp    UNCONN  0       0                                       [::]:3702                                               [::]:*                                    users:(("wsdd2",pid=781,fd=9))                    
udp    UNCONN  0       0                                       [::]:60180                                              [::]:*                                    users:(("wsdd2",pid=781,fd=19))                   
udp    UNCONN  0       0                                       [::]:60180                                              [::]:*                                    users:(("wsdd2",pid=781,fd=20))                   
udp    UNCONN  0       0                                       [::]:60180                                              [::]:*                                    users:(("wsdd2",pid=781,fd=21))                   
tcp    LISTEN  0       5                             0.0.0.0%enp0s9:60180                                           0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=24))                   
tcp    LISTEN  0       5                             0.0.0.0%enp0s8:60180                                           0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=23))                   
tcp    LISTEN  0       5                             0.0.0.0%enp0s3:60180                                           0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=22))                   
tcp    LISTEN  0       5                             0.0.0.0%enp0s9:3702                                            0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=12))                   
tcp    LISTEN  0       5                             0.0.0.0%enp0s8:3702                                            0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=11))                   
tcp    LISTEN  0       5                             0.0.0.0%enp0s3:3702                                            0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=10))                   
tcp    LISTEN  0       5                                [::]%enp0s3:60180                                              [::]:*                                    users:(("wsdd2",pid=781,fd=25))                   
tcp    LISTEN  0       5                                [::]%enp0s8:60180                                              [::]:*                                    users:(("wsdd2",pid=781,fd=26))                   
tcp    LISTEN  0       5                                [::]%enp0s9:60180                                              [::]:*                                    users:(("wsdd2",pid=781,fd=27))                   
tcp    LISTEN  0       5                                [::]%enp0s3:3702                                               [::]:*                                    users:(("wsdd2",pid=781,fd=13))                   
tcp    LISTEN  0       5                                [::]%enp0s8:3702                                               [::]:*                                    users:(("wsdd2",pid=781,fd=14))                   
tcp    LISTEN  0       5                                [::]%enp0s9:3702                                               [::]:*                                    users:(("wsdd2",pid=781,fd=15))

Windows requests are not answered:

# tcpdump -i enp0s9 port 5355
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on enp0s9, link-type EN10MB (Ethernet), capture size 262144 bytes
09:04:53.115228 IP6 fe80::d5e5:baaf:9db6:923d.64491 > ff02::1:3.hostmon: UDP, length 24
09:04:53.115319 IP 192.168.2.11.64491 > 224.0.0.252.hostmon: UDP, length 24
09:04:53.115469 IP6 fe80::d5e5:baaf:9db6:923d.56007 > ff02::1:3.hostmon: UDP, length 24
09:04:53.115554 IP 192.168.2.11.56007 > 224.0.0.252.hostmon: UDP, length 24
09:04:53.529688 IP6 fe80::d5e5:baaf:9db6:923d.56007 > ff02::1:3.hostmon: UDP, length 24
09:04:53.529745 IP6 fe80::d5e5:baaf:9db6:923d.64491 > ff02::1:3.hostmon: UDP, length 24
09:04:53.529757 IP 192.168.2.11.64491 > 224.0.0.252.hostmon: UDP, length 24
09:04:53.529777 IP 192.168.2.11.56007 > 224.0.0.252.hostmon: UDP, length 24

wsdd2 1.8.3.1, CentOS 8.

marcosfrm commented 4 years ago

https://github.com/Andy2244/wsdd2/blob/3b2a6a476b47822e7231a0f209c725489da50801/wsdd2.c#L296

se->s_port is network byte order, need to convert it.

--- wsdd2.c 2020-10-24 11:45:05.000000000 -0300
+++ wsdd2.c 2020-11-16 16:14:56.893012274 -0300
@@ -293,7 +293,7 @@
        };
        struct servent *se = getservbyname(sv->port_name,
                        servicename[sv->type]);
-       ep->port = se ? se->s_port : 0;
+       ep->port = se ? ntohs(se->s_port) : 0;
        if (!ep->port)
            ep->port = sv->port_num;
        if (!ep->port) {

At least now it will use the right port. Still not working though.

marcosfrm commented 3 years ago

Working after @vovcat changes. Closing.