Hi guys,
I have a daemon running on Debian and listening for multicast packets
sent to (ZeroConf Multicast DNS queries).
The server is plugged into a VLAN trunk with eth0 and joins several
VLANs using virtual interfaces (i.e. eth0.xxx). It should be able to
capture the UDP packets on any interfaces, so it spawns a thread for
each interface specified in a config file, and for each thread it
creates a socket:

/************************************************** ************************************/
// Inside a function whose parameters are:
// int *sfd - the socket file descriptor
// struct in_addr bound_ip - the IP on which to listen

#define PORT 5353
#define MGRP ""

struct sockaddr_in addr;
struct ip_mreq mc;

*sfd = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );

bzero( &addr, sizeof( addr ) );
addr.sin_family = AF_INET;
addr.sin_port = htons( PORT );
addr.sin_addr = bound_ip;

bind( *sfd, (struct sockaddr *) &addr, sizeof(addr));

int flag = 1;
mc.imr_multiaddr.s_addr = inet_addr( MGRP );
mc.imr_interface = bound_ip;

setsockopt( *sfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mc, sizeof(mc));
setsockopt( *sfd, SOL_SOCKET, SO_REUSEADDR, (char *) &flag,
setsockopt( *sfd, SOL_SOCKET, SO_REUSEPORT, (char *) &flag,

/************************************************** ************************************/

The problem is that the server captures the UDP packets sent to the
Multicast group only when bound_ip is set to 0 (INADDR_ANY), and even
then, only when the packets are coming on the first interface (eth0).

If I see right, the problem could be that I want to capture packets
sent to while listening on IP, say, But even
then, how could one specify on which interface to listen for a
Multicast packet?

What I'd like is to
- be able to specify several interfaces and spawn one daemon for each
- receive Multicast UDP packets only on the specified interfaces

Any hints are appreciated

Thank you,