wsdd icon indicating copy to clipboard operation
wsdd copied to clipboard

Need help on multicast route config on linux

Open idreamerhx opened this issue 8 years ago • 3 comments

Thanks for your project onvif_srvd and wsdd.

I can run the two projects up. According to

// Join the multicast group 239.255.255.250 on the local interface
// interface. Note that this IP_ADD_MEMBERSHIP option must be
// called for each local interface over which the multicast
// datagrams are to be received.

in wsdd.c I add route in linux: route add -net 239.255.255.250 netmask 255.255.255.255 eth0

Then I run wsdd_debug, It output: Cant adding multicast group error:

So, how should I do?

By the way, I modify the code to udp port 3702: void init_gsoap() { // init gsoap server for WS-Discovery service

soap_srv = soap_new1(SOAP_IO_UDP);

Thanks!

idreamerhx avatar Nov 10 '17 04:11 idreamerhx

Hello.

  1. You do not have to change the port! WSDD uses the default port 3702. This is fixed in the macro WSDD_SERVER_PORT (see the file wsdd_param.h) and is used repeatedly in the "Hello" response, see the macro SOAP_WSDD_TS_ADDRESS.

  2. You do not have to do additional manipulations with the OS. I do not do anything like: (ip route add 239.255.255.250 dev eth0)

  3. I use Ubuntu 16.04 and it is enough for me to do the following steps:

git clone https://github.com/KoynovStas/wsdd.git
cd wsdd /
make
./S90wsdd start

You can use htop + Filter (F4) you should see the running service

Perhaps your Linux requires that you be added to an additional group (I do not know) try to run with administrator rights! Use sudo: sudo ./S90wsdd start

Or you use a new format for Network devices (Ethernet) (not eth0, eth1 ...) You must use the name of your interface use ifconfig for information. I just use the old format (eth0, eth1 ...) see more: changing-network-interfaces-name-ubuntu-16-04

KoynovStas avatar Nov 10 '17 05:11 KoynovStas

I got exactly the same error while playing around with it on an arm device.

I still can't figure out what exactly is causing the problem but I fixed it simply by listening on all devices by changing:

    mcast.imr_multiaddr.s_addr = inet_addr(WSDD_MULTICAST_IP);
    if( get_addr_of_if(wsdd_param.if_name, AF_INET, &mcast.imr_address) != 0 )
    {
        daemon_error_exit("Cant get addr for interface error: %m\n");
    }

    setsockopt(soap_srv->master, IPPROTO_IP, IP_MULTICAST_IF, &mcast.imr_address.s_addr, sizeof(struct in_addr));

    if(setsockopt(soap_srv->master, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&mcast, sizeof(mcast)) != 0 )
    {
        daemon_error_exit("Cant adding multicast group error: %m\n");
    } 

to

    mcast.imr_multiaddr.s_addr = inet_addr(WSDD_MULTICAST_IP);
    mcast.imr_interface.s_addr = htonl(INADDR_ANY);
    if(setsockopt(soap_srv->master, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mcast, sizeof(mcast)) != 0 )
    {
        daemon_error_exit("Cant adding multicast group error: %m\n");
    } 

gaggi avatar Jan 25 '19 11:01 gaggi

    struct ip_mreq mcast;
    mcast.imr_multiaddr.s_addr = inet_addr(WSDD_MULTICAST_IP);
    if( get_addr_of_if(wsdd_param.if_name, AF_INET, &mcast.imr_interface) != 0 )
    {
        daemon_error_exit("Cant get addr for interface error: %m\n");
    }

    if(setsockopt(soap_srv->master, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mcast, sizeof(mcast)) != 0 )
    {
        daemon_error_exit("Cant adding multicast group error: %m\n");
    }

I think this will be better, which will set up multicast on specific Nic. please have a try. @gaggi

goodloop avatar Aug 06 '19 14:08 goodloop

I had the same issue on arm. The fix is this. Hope you can add it in.

diff --git a/src/wsdd.c b/src/wsdd.c index 8fe93eb..6fe0a44 100644 --- a/src/wsdd.c +++ b/src/wsdd.c @@ -336,6 +336,7 @@ void init_gsoap() // datagrams are to be received. struct ip_mreqn mcast; mcast.imr_multiaddr.s_addr = inet_addr(WSDD_MULTICAST_IP); + mcast.imr_ifindex = if_nametoindex(wsdd_param.if_name); if( get_addr_of_if(wsdd_param.if_name, AF_INET, &mcast.imr_address) != 0 ) { daemon_error_exit("Cant get addr for interface error: %m\n");

HarshahSagar avatar May 25 '23 03:05 HarshahSagar