Subject: Re: pkgsrc/wakeup with multiple interfaces
To: None <>
From: David Young <>
List: current-users
Date: 12/12/2005 01:02:29
On Mon, Dec 12, 2005 at 12:18:35AM -0600, John F wrote:
> Hi all!
> 	I'm trying to figure out how to make a C program send out a udp 
> packet to the broadcast address and select which interface is used.


Reading your patch, it looks like it gets the interface-specific source
using select_if, and then overwrites it with INADDR_ANY before calling
bind(2).  Maybe you are on the right track, you just have a bug?

For a multicast UDP socket, I specify the outbound interface by its
ifindex, like this:

        uint32_t addr;

        addr = htonl(ifindex);
        if (setsockopt(s, IPPROTO_IP, IP_MULTICAST_IF, &addr,
            (socklen_t)sizeof(addr)) == -1)
                err(EXIT_FAILURE, "%s: setsockopt(IP_MULTICAST_IF)", __func__);

ISTR this was not documented very well in the manual page ip(4).


David Young             OJC Technologies      Urbana, IL * (217) 278-3933